mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 05:31:22 +00:00
fix: filter by simpleProduct
This commit is contained in:
parent
09bc41bb2f
commit
15d740e85f
@ -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 = {
|
||||||
|
$and: [
|
||||||
|
filter,
|
||||||
|
{
|
||||||
_id: { $in: productIds },
|
_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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user