From 4eac6bc2338f6a7bca20bdf68b56d6720b19488c Mon Sep 17 00:00:00 2001 From: Thalyta Fabrine Date: Wed, 15 Mar 2023 09:56:23 -0300 Subject: [PATCH] Fix issue with shipping option filter that was being ignored --- CHANGELOG.md | 3 +++ node/resolvers/search/index.ts | 15 +++++++++------ node/yarn.lock | 9 ++++++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f69d5bfa..0a6cefe3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- Shipping options filter. + ## [1.64.1] - 2023-02-27 ### Added diff --git a/node/resolvers/search/index.ts b/node/resolvers/search/index.ts index 67e35eb0..2e4a9ef6 100644 --- a/node/resolvers/search/index.ts +++ b/node/resolvers/search/index.ts @@ -337,6 +337,10 @@ export const queries = { } }, facets: async (_: any, args: FacetsInput, ctx: any) => { + const [shippingOptions, facets] = getShippingOptionsFromSelectedFacets(args.selectedFacets) + + args.selectedFacets = facets + args = (await getCompatibilityArgsFromSelectedFacets( ctx, args @@ -355,9 +359,7 @@ export const queries = { // unnecessary field. It's is an object and breaks the @vtex/api cache delete biggyArgs.selectedFacets - const [shippingOptions, facets] = getShippingOptionsFromSelectedFacets(selectedFacets) - - const result = await intelligentSearchApi.facets({...biggyArgs, query: args.fullText}, buildAttributePath(facets), shippingOptions) + const result = await intelligentSearchApi.facets({...biggyArgs, query: args.fullText}, buildAttributePath(selectedFacets), shippingOptions) if (ctx.vtex.tenant) { ctx.translated = result.translated @@ -492,6 +494,9 @@ export const queries = { }, productSearch: async (_: any, args: ProductSearchInput, ctx: any) => { + const [shippingOptions, facets] = getShippingOptionsFromSelectedFacets(args.selectedFacets) + args.selectedFacets = facets + args = (await getCompatibilityArgsFromSelectedFacets( ctx, args @@ -524,9 +529,7 @@ export const queries = { // unnecessary field. It's is an object and breaks the @vtex/api cache delete biggyArgs.selectedFacets - const [shippingOptions, facets] = getShippingOptionsFromSelectedFacets(selectedFacets) - - const result = await intelligentSearchApi.productSearch({...biggyArgs}, buildAttributePath(facets), shippingOptions) + const result = await intelligentSearchApi.productSearch({...biggyArgs}, buildAttributePath(selectedFacets), shippingOptions) if (ctx.vtex.tenant && !args.productOriginVtex) { ctx.translated = result.translated diff --git a/node/yarn.lock b/node/yarn.lock index 6455ac88..0409e3e2 100644 --- a/node/yarn.lock +++ b/node/yarn.lock @@ -1140,7 +1140,14 @@ axios@0.18.0: follow-redirects "^1.3.0" is-buffer "^1.1.5" -axios@^0.21.1, axios@^0.21.2: +axios@^0.21.1: + version "0.21.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" + integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== + dependencies: + follow-redirects "^1.14.0" + +axios@^0.21.2: version "0.21.2" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017" integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==