diff --git a/CHANGELOG.md b/CHANGELOG.md index c64949d845..d4da8db453 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.11.0-rc.2] - unreleased + +### Fixed + + - Fixed problem around dynamic urls when default storeView is set with appendStoreCode false and url set to / . @resubaka (#3685) + ## [1.11.0-rc.1] - 2019.10.03 ### Added diff --git a/core/lib/multistore.ts b/core/lib/multistore.ts index e0b1244245..249b45ee51 100644 --- a/core/lib/multistore.ts +++ b/core/lib/multistore.ts @@ -141,8 +141,11 @@ export function localizedDispatcherRoute (routeObj: LocalizedRoute | string, sto return routeObj } -export function localizedDispatcherRouteName (routeName: string, storeCode: string): string { - return storeCode ? `${storeCode}-${routeName}` : routeName +export function localizedDispatcherRouteName (routeName: string, storeCode: string, appendStoreCode: boolean = false): string { + if (appendStoreCode) { + return `${storeCode}-${routeName}` + } + return routeName } export function localizedRoute (routeObj: LocalizedRoute | string | RouteConfig | RawLocation, storeCode: string): any { diff --git a/core/modules/catalog-next/store/category/actions.ts b/core/modules/catalog-next/store/category/actions.ts index b9de48da1d..5a1a9a5f8e 100644 --- a/core/modules/catalog-next/store/category/actions.ts +++ b/core/modules/catalog-next/store/category/actions.ts @@ -109,14 +109,14 @@ const actions: ActionTree = { }) }, async registerCategoryProductsMapping ({ dispatch }, products = []) { - const storeCode = currentStoreView().storeCode + const { storeCode, appendStoreCode } = currentStoreView() await Promise.all(products.map(product => { const { url_path, sku, slug, type_id } = product return dispatch('url/registerMapping', { url: localizedDispatcherRoute(url_path, storeCode), routeData: { params: { parentSku: product.sku, slug }, - 'name': localizedDispatcherRouteName(type_id + '-product', storeCode) + 'name': localizedDispatcherRouteName(type_id + '-product', storeCode, appendStoreCode) } }, { root: true }) })) diff --git a/core/modules/catalog/store/category/actions.ts b/core/modules/catalog/store/category/actions.ts index a98f491cd6..9ac14abc9f 100644 --- a/core/modules/catalog/store/category/actions.ts +++ b/core/modules/catalog/store/category/actions.ts @@ -63,7 +63,7 @@ const actions: ActionTree = { return list }, async registerCategoryMapping ({ dispatch }, { categories }) { - const storeCode = currentStoreView().storeCode + const { storeCode, appendStoreCode } = currentStoreView() for (let category of categories) { if (category.url_path) { await dispatch('url/registerMapping', { @@ -72,7 +72,7 @@ const actions: ActionTree = { params: { 'slug': category.slug }, - 'name': localizedDispatcherRouteName('category', storeCode) + 'name': localizedDispatcherRouteName('category', storeCode, appendStoreCode) } }, { root: true }) } diff --git a/core/modules/catalog/store/product/actions.ts b/core/modules/catalog/store/product/actions.ts index 46e9b99590..49fd45011d 100644 --- a/core/modules/catalog/store/product/actions.ts +++ b/core/modules/catalog/store/product/actions.ts @@ -296,7 +296,7 @@ const actions: ActionTree = { return searchResult }, preConfigureAssociated (context, { searchResult, prefetchGroupProducts }) { - const storeCode = currentStoreView().storeCode + const { storeCode, appendStoreCode } = currentStoreView() for (let product of searchResult.items) { if (product.url_path) { const { parentSku, slug } = product @@ -305,7 +305,7 @@ const actions: ActionTree = { url: localizedDispatcherRoute(product.url_path, storeCode), routeData: { params: { parentSku, slug }, - 'name': localizedDispatcherRouteName(product.type_id + '-product', storeCode) + 'name': localizedDispatcherRouteName(product.type_id + '-product', storeCode, appendStoreCode) } }, { root: true }) } diff --git a/core/modules/url/store/actions.ts b/core/modules/url/store/actions.ts index 66568ccd9f..cb59ae9ca5 100644 --- a/core/modules/url/store/actions.ts +++ b/core/modules/url/store/actions.ts @@ -66,7 +66,7 @@ export const actions: ActionTree = { * This method could be overriden in custom module to provide custom URL mapping logic */ async mappingFallback ({ dispatch }, { url, params }: { url: string, params: any}) { - const storeCode = currentStoreView().storeCode + const { storeCode, appendStoreCode } = currentStoreView() const productQuery = new SearchQuery() url = (removeStoreCodeFromRoute(url.startsWith('/') ? url.slice(1) : url) as string) productQuery.applyFilter({key: 'url_path', value: {'eq': url}}) // Tees category @@ -74,7 +74,7 @@ export const actions: ActionTree = { if (products && products.items && products.items.length) { const product = products.items[0] return { - name: localizedDispatcherRouteName(product.type_id + '-product', storeCode), + name: localizedDispatcherRouteName(product.type_id + '-product', storeCode, appendStoreCode), params: { slug: product.slug, parentSku: product.sku, @@ -85,7 +85,7 @@ export const actions: ActionTree = { const category = await dispatch('category/single', { key: 'url_path', value: url }, { root: true }) if (category !== null) { return { - name: localizedDispatcherRouteName('category', storeCode), + name: localizedDispatcherRouteName('category', storeCode, appendStoreCode), params: { slug: category.slug }