Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 50e5518

Browse files
authored
Merge branch 'develop' into feature/#2458-filters-adjustment
2 parents f206ea1 + a0100f6 commit 50e5518

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

core/modules/catalog/store/product/actions.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue'
22
import { ActionTree } from 'vuex'
33
import * as types from './mutation-types'
4-
import { breadCrumbRoutes, productThumbnailPath } from '@vue-storefront/core/helpers'
4+
import { breadCrumbRoutes, productThumbnailPath, isServer } from '@vue-storefront/core/helpers'
55
import { currentStoreView } from '@vue-storefront/core/lib/multistore'
66
import { configureProductAsync,
77
doPlatformPricesSync,
@@ -617,18 +617,20 @@ const actions: ActionTree<ProductState, RootState> = {
617617
const productFields = Object.keys(product).filter(fieldName => {
618618
return rootStore.state.config.entities.product.standardSystemFields.indexOf(fieldName) < 0 // don't load metadata info for standard fields
619619
})
620-
subloaders.push(context.dispatch('attribute/list', { // load attributes to be shown on the product details - the request is now async
620+
const attributesPromise = context.dispatch('attribute/list', { // load attributes to be shown on the product details - the request is now async
621621
filterValues: rootStore.state.config.entities.product.useDynamicAttributeLoader ? productFields : null,
622622
only_visible: rootStore.state.config.entities.product.useDynamicAttributeLoader ? true : false,
623623
only_user_defined: true,
624624
includeFields: rootStore.state.config.entities.optimize ? rootStore.state.config.entities.attribute.includeFields : null
625-
}, { root: true }))
625+
}, { root: true }) // TODO: it might be refactored to kind of: `await context.dispatch('attributes/list) - or using new Promise() .. to wait for attributes to be loaded before executing the next action. However it may decrease the performance - so for now we're just waiting with the breadcrumbs
626626
if (Vue.prototype.$isServer) {
627+
subloaders.push(context.dispatch('setupBreadcrumbs', { product: product }))
627628
subloaders.push(context.dispatch('filterUnavailableVariants', { product: product }))
628629
} else {
630+
attributesPromise.then(() => context.dispatch('setupBreadcrumbs', { product: product })) // if this is client's side request postpone breadcrumbs setup till attributes are loaded to avoid too-early breadcrumb switch #2469
629631
context.dispatch('filterUnavailableVariants', { product: product }) // exec async
630632
}
631-
subloaders.push(context.dispatch('setupBreadcrumbs', { product: product }))
633+
subloaders.push(attributesPromise)
632634

633635
// subloaders.push(context.dispatch('setupVariants', { product: product })) -- moved to "product/single"
634636
/* if (product.type_id === 'grouped' || product.type_id === 'bundle') { -- moved to "product/single"

0 commit comments

Comments
 (0)