From c173b47ac9cebef796c509887a4c840e23ca9d8a Mon Sep 17 00:00:00 2001 From: tniezg Date: Wed, 28 Jul 2021 16:58:35 +0200 Subject: [PATCH] Search products by name --- framework/spree/product/use-search.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/framework/spree/product/use-search.tsx b/framework/spree/product/use-search.tsx index 6eafc6a92..f9beac38c 100644 --- a/framework/spree/product/use-search.tsx +++ b/framework/spree/product/use-search.tsx @@ -31,14 +31,12 @@ export const handler: SWRHook = { const taxons = [input.categoryId, input.brandId].filter(Boolean) - const filter = - taxons.length > 0 - ? { - filter: { - taxons: taxons.join(','), - }, - } - : {} + const filter = { + filter: { + ...(taxons.length > 0 ? { taxons: taxons.join(',') } : {}), + ...(input.search ? { name: input.search } : {}), + }, + } const sort = input.sort ? { sort: nextToSpreeSortMap[input.sort] } : {}