Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve payload preparation for search products(#1x69mn1) #30

Merged
merged 1 commit into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelogs/unreleased/-1x69mn1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Improve payload preparation for search products
ticket_id: "#1x69mn1"
merge_request: 30
author: Yashi Verma
type: changed
3 changes: 2 additions & 1 deletion src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ const actions: ActionTree<ProductState, RootState> = {
async fetchProducts ( { commit, state }, { productIds }) {
const cachedProductIds = Object.keys(state.cached);
const productIdFilter= productIds.reduce((filter: string, productId: any) => {
if (filter !== '') filter += ' OR '
// If product already exist in cached products skip
if (cachedProductIds.includes(productId)) {
return filter;
} else {
// checking condition that if the filter is not empty then adding 'OR' to the filter
if (filter !== '') filter += ' OR '
return filter += productId;
}
}, '');
Expand Down