fix: filter by simpleProduct

This commit is contained in:
Gérard Le Cloerec 2021-04-07 16:55:27 +02:00
parent 09bc41bb2f
commit 15d740e85f

View File

@ -41,19 +41,17 @@ const getProducts: ProductsHandlers['getProducts'] = async ({
}, },
}), }),
}) })
const productIds: string[] = cat.productsList const productIds: string[] = cat.productsList
.filter((p: any) => p.checked) .filter((p: any) => p.checked)
.map((p: any) => p.id) .map((p: any) => p.id)
// if (search) {
// filter = {
// $and: [{ ...filter }, { _id: { $in: productIds } }],
// }
// } else {
filter = { filter = {
_id: { $in: productIds }, $and: [
filter,
{
_id: { $in: productIds },
},
],
} }
// }
} }
if (sortParam) { if (sortParam) {
@ -74,7 +72,23 @@ const getProducts: ProductsHandlers['getProducts'] = async ({
} }
} }
} }
console.log(
JSON.stringify({
lang: 'en',
PostBody: {
filter,
structure: {
canonical: 1,
reviews: 1,
stock: 1,
universe: 1,
},
sort,
page: 1,
limit: LIMIT,
},
})
)
const { datas } = await config.storeApiFetch('/v2/products', { const { datas } = await config.storeApiFetch('/v2/products', {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
@ -87,7 +101,6 @@ const getProducts: ProductsHandlers['getProducts'] = async ({
stock: 1, stock: 1,
universe: 1, universe: 1,
}, },
// populate: ['bundle_sections.products.id'],
sort, sort,
page: 1, page: 1,
limit: LIMIT, limit: LIMIT,