From 368b32c2112de13b272607c725cd16d71fb0ca51 Mon Sep 17 00:00:00 2001 From: tkostuch Date: Thu, 19 Dec 2019 12:55:26 +0100 Subject: [PATCH 1/2] product breadcrumbs - check if current category is highest one --- core/modules/catalog-next/store/category/actions.ts | 2 +- core/modules/catalog/store/product/actions.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/modules/catalog-next/store/category/actions.ts b/core/modules/catalog-next/store/category/actions.ts index a804b3fb5d..2d6cd06508 100644 --- a/core/modules/catalog-next/store/category/actions.ts +++ b/core/modules/catalog-next/store/category/actions.ts @@ -130,7 +130,7 @@ const actions: ActionTree = { }, async loadCategories ({ commit, getters }, categorySearchOptions: DataResolver.CategorySearchOptions): Promise { const searchingByIds = !(!categorySearchOptions || !categorySearchOptions.filters || !categorySearchOptions.filters.id) - const searchedIds: string[] = searchingByIds ? ([...categorySearchOptions.filters.id] as string[]) : [] + const searchedIds: string[] = searchingByIds ? [...categorySearchOptions.filters.id].map(String) : [] const loadedCategories: Category[] = [] if (searchingByIds && !categorySearchOptions.reloadAll) { // removing from search query already loaded categories, they are added to returned results for (const [categoryId, category] of Object.entries(getters.getCategoriesMap)) { diff --git a/core/modules/catalog/store/product/actions.ts b/core/modules/catalog/store/product/actions.ts index 964033e85f..35c9290383 100644 --- a/core/modules/catalog/store/product/actions.ts +++ b/core/modules/catalog/store/product/actions.ts @@ -687,7 +687,11 @@ const actions: ActionTree = { let breadcrumbCategory const categoryFilters = Object.assign({ 'id': [...product.category_ids] }, cloneDeep(config.entities.category.breadcrumbFilterFields)) const categories = await dispatch('category-next/loadCategories', { filters: categoryFilters, reloadAll: Object.keys(config.entities.category.breadcrumbFilterFields).length > 0 }, { root: true }) - if (currentCategory && currentCategory.id && (categories.findIndex(category => category.id === currentCategory.id) >= 0)) { + if ( + (currentCategory && currentCategory.id) && // current category exist + (config.entities.category.categoriesRootCategorylId !== currentCategory.id) && // is not highest category (All) - if we open product from different page then category page + (categories.findIndex(category => category.id === currentCategory.id) >= 0) // can be found in fetched categories + ) { breadcrumbCategory = currentCategory // use current category if set and included in the filtered list } else { breadcrumbCategory = categories.sort((a, b) => (a.level > b.level) ? -1 : 1)[0] // sort starting by deepest level From 5b5c3d2006e1e0fabb26f59760845de8d2fd7088 Mon Sep 17 00:00:00 2001 From: tkostuch Date: Thu, 19 Dec 2019 13:01:57 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f18593992..3429cf8ad3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed error page display with enabled multistore - @gibkigonzo (#3890) - Fixed edit shipping address in my account - @gibkigonzo (#3921) - Fetch cms_block content in serverPrefetch method - @gibkigonzo (#3910) +- product breadcrumbs - check if current category is not highest one - @gibkigonzo (#3933) ### Changed / Improved - Changed pre commit hook to use NODE_ENV production to check for debugger statements - @resubaka (#3686)