Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- update getCurrentCartHash after add/remove coupon - @gibkigonzo (#4220)
- update replaceNumberToString, so it will change ONLY numbers to string - @gibkigonzo (#4217)
- allow empty shipping methods in checkout - @gibkigozno (#4192)
- configure products before price update - this is needed to have variant sku as product sku - @gibkigonzo (#4053)

## [1.11.2] - 2020.03.10

Expand Down
1 change: 1 addition & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@
"sort": "updated_at:desc",
"includeFields": [
"activity",
"configurable_children.id",
"configurable_children.final_price",
"configurable_children.color",
"configurable_children.original_price",
Expand Down
8 changes: 4 additions & 4 deletions core/modules/catalog-next/store/category/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ const actions: ActionTree<CategoryState, RootState> = {
* Configures products
*/
async processCategoryProducts ({ dispatch, rootState }, { products = [], filters = {} } = {}) {
await dispatch('tax/calculateTaxes', { products: products }, { root: true })
const configuredProducts = await dispatch('configureProducts', { products, filters })
dispatch('registerCategoryProductsMapping', products) // we don't need to wait for this
return dispatch('configureProducts', { products, filters })
return dispatch('tax/calculateTaxes', { products: configuredProducts }, { root: true })
},
/**
* Configure configurable products to have first available options selected
* so they can be added to cart/wishlist/compare without manual configuring
*/
async configureProducts ({ rootState }, { products = [], filters = {} } = {}) {
async configureProducts ({ rootState }, { products = [], filters = {}, populateRequestCacheTags = config.server.useOutputCacheTagging } = {}) {
return products.map(product => {
product = Object.assign({}, preConfigureProduct({ product, populateRequestCacheTags: config.server.useOutputCacheTagging }))
product = Object.assign({}, preConfigureProduct({ product, populateRequestCacheTags }))
const configuredProductVariant = configureProductAsync({ rootState, state: { current_configuration: {} } }, { product, configuration: filters, selectDefaultVariant: false, fallbackToDefaultWhenNoAvailable: true, setProductErorrs: false })
return Object.assign(product, omit(configuredProductVariant, ['visibility']))
})
Expand Down
24 changes: 14 additions & 10 deletions core/modules/catalog/store/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const actions: ActionTree<ProductState, RootState> = {
* Setup product breadcrumbs path
*/
async setupBreadcrumbs (context, { product }) {
console.warn('deprecated, will be removed in 1.13')
let breadcrumbsName = null
let setBreadcrumbRoutesFromPath = (path) => {
if (path.findIndex(itm => {
Expand Down Expand Up @@ -317,6 +318,7 @@ const actions: ActionTree<ProductState, RootState> = {
}
},
preConfigureProduct (context, { product, populateRequestCacheTags, configuration }) {
console.warn('deprecated, will be removed in 1.13')
let prod = preConfigureProduct({ product, populateRequestCacheTags })

if (configuration) {
Expand All @@ -327,19 +329,21 @@ const actions: ActionTree<ProductState, RootState> = {
return prod
},
async configureLoadedProducts (context, { products, isCacheable, cacheByKey, populateRequestCacheTags, configuration }) {
if (products.items && products.items.length) { // preconfigure products; eg: after filters
for (let product of products.items) {
product = await context.dispatch('preConfigureProduct', { product, populateRequestCacheTags, configuration }) // preConfigure(product)
}
}

await context.dispatch('tax/calculateTaxes', { products: products.items }, { root: true })
const configuredProducts = await context.dispatch(
'category-next/configureProducts',
{
products: products.items,
filters: configuration || {},
populateRequestCacheTags
},
{ root: true }
)

for (let prod of products.items) { // we store each product separately in cache to have offline access to products/single method
prod = configureChildren(prod)
await context.dispatch('tax/calculateTaxes', { products: configuredProducts }, { root: true })

for (let product of configuredProducts) { // we store each product separately in cache to have offline access to products/single method
if (isCacheable) { // store cache only for full loads
storeProductToCache(prod, cacheByKey)
storeProductToCache(product, cacheByKey)
}
}

Expand Down