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

Improved: Fetched product identifier options dynamically (#345). #346

Merged
merged 2 commits into from
Oct 25, 2024
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
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();
}
}
})
Loading