diff --git a/app/home/(user)/_lib/server/load-analysis-packages.ts b/app/home/(user)/_lib/server/load-analysis-packages.ts index 3dc758d..59da4ae 100644 --- a/app/home/(user)/_lib/server/load-analysis-packages.ts +++ b/app/home/(user)/_lib/server/load-analysis-packages.ts @@ -1,6 +1,6 @@ import { cache } from 'react'; -import { listCollections, listProducts, listRegions } from "@lib/data"; +import { listProductTypes, listProducts, listRegions } from "@lib/data"; async function countryCodesLoader() { const countryCodes = await listRegions().then((regions) => @@ -10,26 +10,24 @@ async function countryCodesLoader() { } export const loadCountryCodes = cache(countryCodesLoader); -async function collectionsLoader() { - const { collections } = await listCollections({ - fields: 'id, handle', - }); - return collections ?? []; +async function productTypesLoader() { + const { productTypes } = await listProductTypes(); + return productTypes ?? []; } -export const loadCollections = cache(collectionsLoader); +export const loadProductTypes = cache(productTypesLoader); async function analysisPackagesLoader() { - const [countryCodes, collections] = await Promise.all([loadCountryCodes(), loadCollections()]); + const [countryCodes, productTypes] = await Promise.all([loadCountryCodes(), loadProductTypes()]); const countryCode = countryCodes[0]!; - const collection = collections.find(({ handle }) => handle === 'analysis-packages'); - if (!collection) { + const productType = productTypes.find(({ metadata }) => metadata?.handle === 'analysis-packages'); + if (!productType) { return { analysisPackages: [], countryCode }; } const { response } = await listProducts({ countryCode, - queryParams: { limit: 100, collection_id: collection?.id }, + queryParams: { limit: 100, "type_id[0]": productType.id }, }); return { analysisPackages: response.products, countryCode }; } diff --git a/packages/features/medusa-storefront/src/lib/data/products.ts b/packages/features/medusa-storefront/src/lib/data/products.ts index d671d2c..810d205 100644 --- a/packages/features/medusa-storefront/src/lib/data/products.ts +++ b/packages/features/medusa-storefront/src/lib/data/products.ts @@ -14,7 +14,7 @@ export const listProducts = async ({ regionId, }: { pageParam?: number - queryParams?: HttpTypes.FindParams & HttpTypes.StoreProductParams & { collection_id?: string } + queryParams?: HttpTypes.FindParams & HttpTypes.StoreProductParams & { "type_id[0]"?: string } countryCode?: string regionId?: string }): Promise<{