Skip to content

Commit

Permalink
Fixed: solr query for fetching products on count page
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Jan 12, 2024
1 parent 7b4a40b commit 812d781
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const actions: ActionTree<ProductState, RootState> = {
}
const productQueryPayload = prepareProductQuery(params)
resp = await ProductService.fetchProducts(productQueryPayload)

// resp.data.response.numFound tells the number of items in the response
if (resp.status === 200 && resp.data.response?.numFound > 0 && !hasError(resp)) {
let products = resp.data.response.docs;
Expand Down Expand Up @@ -97,10 +96,17 @@ const actions: ActionTree<ProductState, RootState> = {
if(currentProduct) {
commit(types.PRODUCT_CURRENT_UPDATED, { product: currentProduct })
} else {
const resp = await ProductService.fetchProducts({
// used sku as we are currently only using sku to search for the product
"filters": ['sku: ' + payload, 'isVirtual: false'],
})
// used sku as we are currently only using sku to search for the product
const params = {
filters: {
isVirtual: { value: 'false' },
sku: { value: payload }
}
}
const productQueryPayload = prepareProductQuery(params)

const resp = await ProductService.fetchProducts(productQueryPayload)

if(resp.status === 200 && !hasError(resp) && resp.data.response?.numFound > 0) {
commit(types.PRODUCT_CURRENT_UPDATED, { product: resp.data.response.docs[0] })
} else {
Expand Down

0 comments on commit 812d781

Please sign in to comment.