diff --git a/src/components/DxpProductIdentifier.vue b/src/components/DxpProductIdentifier.vue index 320dbd7..a1c337a 100644 --- a/src/components/DxpProductIdentifier.vue +++ b/src/components/DxpProductIdentifier.vue @@ -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); }) diff --git a/src/index.ts b/src/index.ts index ed451aa..c9c5753 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 diff --git a/src/store/productIdentification.ts b/src/store/productIdentification.ts index b6d87f4..69093a4 100644 --- a/src/store/productIdentification.ts +++ b/src/store/productIdentification.ts @@ -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: { @@ -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(); } } })