mirror of
https://github.com/vercel/commerce.git
synced 2025-07-25 11:11:24 +00:00
Merge branch 'master' into shopify-i18n
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { getConfig, ShopifyConfig } from '../api'
|
||||
import fetchAllProducts from '../api/utils/fetch-all-products'
|
||||
import { ProductEdge } from '../schema'
|
||||
import getAllProductsPathsQuery from '../utils/queries/get-all-products-paths-query'
|
||||
|
||||
@@ -20,21 +19,22 @@ const getAllProductPaths = async (options?: {
|
||||
config?: ShopifyConfig
|
||||
preview?: boolean
|
||||
}): Promise<ReturnType> => {
|
||||
let { config, variables = { first: 250 } } = options ?? {}
|
||||
let { config, variables = { first: 100, sortKey: 'BEST_SELLING' } } =
|
||||
options ?? {}
|
||||
config = getConfig(config)
|
||||
|
||||
const products = await fetchAllProducts({
|
||||
config,
|
||||
query: getAllProductsPathsQuery,
|
||||
const { data } = await config.fetch(getAllProductsPathsQuery, {
|
||||
variables,
|
||||
})
|
||||
|
||||
return {
|
||||
products: products?.map(({ node: { handle } }: ProductEdge) => ({
|
||||
node: {
|
||||
path: `/${handle}`,
|
||||
},
|
||||
})),
|
||||
products: data.products?.edges?.map(
|
||||
({ node: { handle } }: ProductEdge) => ({
|
||||
node: {
|
||||
path: `/${handle}`,
|
||||
},
|
||||
})
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -35,6 +35,7 @@ const getAllProducts = async (options: {
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
products = [
|
||||
...products,
|
||||
...data.products.edges.map(({ node: p }) => normalizeProduct(p)),
|
||||
|
Reference in New Issue
Block a user