diff --git a/packages/magento-product/components/ProductStaticPaths/getProductStaticPaths.ts b/packages/magento-product/components/ProductStaticPaths/getProductStaticPaths.ts index e00858eed0..a8a6eac3f5 100644 --- a/packages/magento-product/components/ProductStaticPaths/getProductStaticPaths.ts +++ b/packages/magento-product/components/ProductStaticPaths/getProductStaticPaths.ts @@ -15,13 +15,24 @@ export async function getProductStaticPaths( ) { const query = client.query({ query: ProductStaticPathsDocument, - variables: { - currentPage: 1, - pageSize: 100, - }, + variables: { currentPage: 1, pageSize: 100 }, }) const pages: Promise>[] = [query] + const { data } = await query + const totalPages = data.products?.page_info?.total_pages ?? 1 + + if (totalPages > 1 && import.meta.graphCommerce.limitSsg !== true) { + for (let i = 2; i <= totalPages; i++) { + pages.push( + client.query({ + query: ProductStaticPathsDocument, + variables: { currentPage: i, pageSize: 100 }, + }), + ) + } + } + const paths: Return['paths'] = (await Promise.all(pages)) .map((q) => q.data.products?.items) .flat(1)