Skip to content

Commit

Permalink
Merge pull request #346 from hotwax/#345_product_identifier_options
Browse files Browse the repository at this point in the history
Improved: Fetched product identifier options dynamically (#345).
  • Loading branch information
ravilodhi authored Oct 25, 2024
2 parents bbbb96e + 4e3d426 commit a076bf5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/DxpProductIdentifier.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ const userStore = useUserStore()
const currentEComStore = computed(() => userStore.getCurrentEComStore)
const productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref);
const productIdentificationOptions = productIdentificationStore.getProductIdentificationOptions;
const productIdentificationOptions = computed(() => productIdentificationStore.getProductIdentificationOptions);
onMounted(() => {
productIdentificationStore.prepareProductIdentifierOptions();
productIdentificationStore.getIdentificationPref(currentEComStore.value.productStoreId);
})
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export let dxpComponents = {

productIdentificationContext.getProductIdentificationPref = options.getProductIdentificationPref
productIdentificationContext.setProductIdentificationPref = options.setProductIdentificationPref
productIdentificationContext.fetchGoodIdentificationTypes = options.fetchGoodIdentificationTypes

facilityContext.getUserFacilities = options.getUserFacilities
facilityContext.setUserPreference = options.setUserPreference
Expand Down
13 changes: 12 additions & 1 deletion src/store/productIdentification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const useProductIdentificationStore = defineStore('productIdentification'
primaryId: '',
secondaryId: ''
},
productIdentificationOptions: ["productId", "groupId", "groupName", "internalName", "parentProductName", "primaryProductCategoryName", "sku", "title", "SHOPIFY_PROD_SKU", "upc"]
productIdentificationOptions: []
}
},
getters: {
Expand Down Expand Up @@ -44,6 +44,17 @@ export const useProductIdentificationStore = defineStore('productIdentification'
}

this.productIdentificationPref = await productIdentificationContext.getProductIdentificationPref(eComStoreId)
},
async prepareProductIdentifierOptions() {
//static identifications
const productIdentificationOptions = ["productId", "groupId", "groupName", "internalName", "parentProductName", "primaryProductCategoryName", "title"];

//good identification types
const fetchedGoodIdentificationTypes = await productIdentificationContext.fetchGoodIdentificationTypes("HC_GOOD_ID_TYPE");
const fetchedGoodIdentificationOptions = fetchedGoodIdentificationTypes?.map((fetchedGoodIdentificationType: any) => fetchedGoodIdentificationType.goodIdentificationTypeId) || [];

// Merge the arrays and remove duplicates
this.productIdentificationOptions = Array.from(new Set([...productIdentificationOptions, ...fetchedGoodIdentificationOptions])).sort();
}
}
})

0 comments on commit a076bf5

Please sign in to comment.