Skip to content

Commit be94e29

Browse files
authored
Merge pull request #6002 from vuestorefront/#5981/update-url-after-change-filter
fix: update url with properly child sku
2 parents b635c0d + d1c7583 commit be94e29

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4444
- Error with unknown theme/index.js alias - @Fifciuu (https://github.com/vuestorefront/vue-storefront/pull/5813)
4545
- ESLint warnings caused by the double import - @lukaszjedrasik
4646
- Fix Order History Pagination - @AishwaryShrivastav / @lukaszjedrasik ([#4599](https://github.com/vuestorefront/vue-storefront/issues/4599))
47+
- Fix: Updating URL's params/query params with proper child SKU if options changes - @lukaszjedrasik ([#5981](https://github.com/vuestorefront/vue-storefront/issues/5981))
4748

4849
### Changed / Improved
4950

core/modules/catalog/events.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export const filterChangedProduct = async (filterOption, store, router) => {
4040
}
4141
}, { root: true })
4242
const { configuration, selectedVariant, options, product_option } = newProductVariant
43+
const routeProp = config.seo.useUrlDispatcher ? 'query' : 'params';
44+
4345
if (config.products.setFirstVarianAsDefaultInURL && selectedVariant) {
44-
const routeProp = config.seo.useUrlDispatcher ? 'params' : 'query'
4546
router.push({ [routeProp]: { childSku: selectedVariant.sku } })
4647
}
4748
if (selectedVariant) {
@@ -53,6 +54,17 @@ export const filterChangedProduct = async (filterOption, store, router) => {
5354
)
5455
await store.dispatch('product/setCurrent', newProductConfiguration)
5556
EventBus.$emit('product-after-configure', { product: newProductConfiguration, configuration: configuration, selectedVariant: selectedVariant })
57+
58+
if (router?.currentRoute?.[routeProp]?.childSku) {
59+
router.push(
60+
{
61+
[routeProp]: {
62+
...router.currentRoute[routeProp],
63+
childSku: selectedVariant.sku
64+
}
65+
}
66+
)
67+
}
5668
return selectedVariant
5769
} else {
5870
store.dispatch('notification/spawnNotification', {

0 commit comments

Comments
 (0)