diff --git a/CHANGELOG.md b/CHANGELOG.md index 9553eee16e..3df1094985 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed edit shipping address in my account - @gibkigonzo (#3921) - Fetch cms_block content in serverPrefetch method - @gibkigonzo (#3910) - Keep category products objects on ssr - @gibkigonzo (#3924) +- 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) 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