From 8909e94a6ab73b4289d7a57729b9abf085c89135 Mon Sep 17 00:00:00 2001 From: Dom Sip Date: Tue, 19 Apr 2022 10:23:25 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Luis Alvarez D. --- packages/sfcc/README.md | 2 +- .../api/endpoints/catalog/products/get-products.ts | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/sfcc/README.md b/packages/sfcc/README.md index 04fe392aa..3b419dcf7 100644 --- a/packages/sfcc/README.md +++ b/packages/sfcc/README.md @@ -21,7 +21,7 @@ } ``` -## Refrences: +## References - SDK: https://github.com/SalesforceCommerceCloud/commerce-sdk - isomorphic SDK (currently not used atm): https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic - PWA Kit storefront example: https://pwa-kit.mobify-storefront.com/ diff --git a/packages/sfcc/src/api/endpoints/catalog/products/get-products.ts b/packages/sfcc/src/api/endpoints/catalog/products/get-products.ts index 2e286ee4c..eb814f5d7 100644 --- a/packages/sfcc/src/api/endpoints/catalog/products/get-products.ts +++ b/packages/sfcc/src/api/endpoints/catalog/products/get-products.ts @@ -10,16 +10,8 @@ const getProducts: ProductsEndpoint['handlers']['getProducts'] = async ({ }) => { const { sdk } = config; - let searchTerm = search; - - if (categoryId) { - searchTerm = categoryId as string - } - - // set default for main category - if (!searchTerm) { - searchTerm = 'clothing' - } + // 'clothing' is our main category default, and a manually set category has priority + const searchTerm = categoryId ? categoryId as string : search || 'clothing'; const searchClient = await sdk.getSearchClient(); // use SDK search API for initial products