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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions core/lib/multistore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions core/modules/catalog-next/store/category/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ const actions: ActionTree<CategoryState, RootState> = {
})
},
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 })
}))
Expand Down
4 changes: 2 additions & 2 deletions core/modules/catalog/store/category/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const actions: ActionTree<CategoryState, RootState> = {
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', {
Expand All @@ -72,7 +72,7 @@ const actions: ActionTree<CategoryState, RootState> = {
params: {
'slug': category.slug
},
'name': localizedDispatcherRouteName('category', storeCode)
'name': localizedDispatcherRouteName('category', storeCode, appendStoreCode)
}
}, { root: true })
}
Expand Down
4 changes: 2 additions & 2 deletions core/modules/catalog/store/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ const actions: ActionTree<ProductState, RootState> = {
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
Expand All @@ -305,7 +305,7 @@ const actions: ActionTree<ProductState, RootState> = {
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 })
}
Expand Down
6 changes: 3 additions & 3 deletions core/modules/url/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ export const actions: ActionTree<UrlState, any> = {
* 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
const products = await dispatch('product/list', { query: productQuery }, { root: true })
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,
Expand All @@ -85,7 +85,7 @@ export const actions: ActionTree<UrlState, any> = {
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
}
Expand Down