mirror of
https://github.com/vercel/commerce.git
synced 2025-07-25 11:11:24 +00:00
refactor category and brand filtering logic
Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
@@ -1,16 +1,30 @@
|
||||
import catalogItemsQuery from '@framework/utils/queries/catalog-items-query'
|
||||
import { normalizeProduct } from '@framework/utils'
|
||||
import type { ProductsEndpoint } from './products'
|
||||
import getSearchVariables from '../../utils/get-search-variables'
|
||||
|
||||
const getCart: ProductsEndpoint['handlers']['getProducts'] = async ({
|
||||
req,
|
||||
res,
|
||||
config,
|
||||
}) => {
|
||||
const {
|
||||
brandId,
|
||||
categoryId,
|
||||
search,
|
||||
sort,
|
||||
} = req.query
|
||||
|
||||
const {
|
||||
data: { catalogItems },
|
||||
} = await config.fetch(catalogItemsQuery, {
|
||||
variables: {
|
||||
...getSearchVariables({
|
||||
brandId,
|
||||
categoryId,
|
||||
search,
|
||||
sort,
|
||||
}),
|
||||
shopIds: [config.shopId],
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user