diff --git a/CHANGELOG.md b/CHANGELOG.md index 11805d1b32..03fc79b752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Use `defaultSortBy` for sorting category products by default @haelbichalex (#3873) - Fixed some potential mutations of Config object in `catalog` and `catalog-next` - @grimasod (#3843) - Set `null` as default value for custom option in product page - @gibkigonzo (#3885) +- Fixed Breadcrumb filters - apply to second category fetch - @grimasod (#3887) - Fixed `config.storeViews.commonCache` being ignored - @grimasod (#3895) ### Changed / Improved diff --git a/core/data-resolver/types/DataResolver.d.ts b/core/data-resolver/types/DataResolver.d.ts index 349d8c9456..f2d40575a3 100644 --- a/core/data-resolver/types/DataResolver.d.ts +++ b/core/data-resolver/types/DataResolver.d.ts @@ -17,7 +17,8 @@ declare namespace DataResolver { start?: number, sort?: string, includeFields?: string[], - excludeFields?: string[] + excludeFields?: string[], + reloadAll?: boolean } interface Customer { diff --git a/core/modules/catalog-next/store/category/actions.ts b/core/modules/catalog-next/store/category/actions.ts index e426b49de5..a804b3fb5d 100644 --- a/core/modules/catalog-next/store/category/actions.ts +++ b/core/modules/catalog-next/store/category/actions.ts @@ -130,9 +130,9 @@ 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] as string[]) : [] const loadedCategories: Category[] = [] - if (searchingByIds) { // removing from search query already loaded categories, they are added to returned results + 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)) { if (searchedIds.includes(categoryId)) { loadedCategories.push(category as Category) @@ -197,8 +197,8 @@ const actions: ActionTree = { async loadCategoryBreadcrumbs ({ dispatch, getters }, { category, currentRouteName, omitCurrent = false }) { if (!category) return const categoryHierarchyIds = _prepareCategoryPathIds(category) // getters.getCategoriesHierarchyMap.find(categoryMapping => categoryMapping.includes(category.id)) - const categoryFilters = { 'id': categoryHierarchyIds } - const categories = await dispatch('loadCategories', {filters: categoryFilters}) + const categoryFilters = Object.assign({ 'id': categoryHierarchyIds }, cloneDeep(config.entities.category.breadcrumbFilterFields)) + const categories = await dispatch('loadCategories', { filters: categoryFilters, reloadAll: Object.keys(config.entities.category.breadcrumbFilterFields).length > 0 }) const sorted = [] for (const id of categoryHierarchyIds) { const index = categories.findIndex(cat => cat.id.toString() === id) diff --git a/core/modules/catalog/store/product/actions.ts b/core/modules/catalog/store/product/actions.ts index f38cc3577f..964033e85f 100644 --- a/core/modules/catalog/store/product/actions.ts +++ b/core/modules/catalog/store/product/actions.ts @@ -683,13 +683,16 @@ const actions: ActionTree = { }, async loadProductBreadcrumbs ({ dispatch, rootGetters }, { product } = {}) { if (product && product.category_ids) { - let currentCategory = rootGetters['category-next/getCurrentCategory'] // use current category, if set - if (!currentCategory || !currentCategory.id || !product.category_ids.includes(currentCategory.id.toString())) { - const categoryFilters = Object.assign({ 'id': [...product.category_ids] }, cloneDeep(config.entities.category.breadcrumbFilterFields)) - const categories = await dispatch('category-next/loadCategories', {filters: categoryFilters}, { root: true }) - currentCategory = categories.sort((a, b) => (a.level > b.level) ? -1 : 1)[0] // sort starting by deepest level + const currentCategory = rootGetters['category-next/getCurrentCategory'] + 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)) { + 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 } - await dispatch('category-next/loadCategoryBreadcrumbs', { category: currentCategory, currentRouteName: product.name }, { root: true }) + await dispatch('category-next/loadCategoryBreadcrumbs', { category: breadcrumbCategory, currentRouteName: product.name }, { root: true }) } } } diff --git a/src/themes/default/components/core/blocks/Checkout/ThankYouPage.vue b/src/themes/default/components/core/blocks/Checkout/ThankYouPage.vue index b2339c44da..b83c01ccae 100644 --- a/src/themes/default/components/core/blocks/Checkout/ThankYouPage.vue +++ b/src/themes/default/components/core/blocks/Checkout/ThankYouPage.vue @@ -4,6 +4,7 @@

diff --git a/src/themes/default/pages/Compare.vue b/src/themes/default/pages/Compare.vue index d999c4d253..3def227e73 100644 --- a/src/themes/default/pages/Compare.vue +++ b/src/themes/default/pages/Compare.vue @@ -2,7 +2,7 @@
- +

{{ title }}

diff --git a/src/themes/default/pages/MyAccount.vue b/src/themes/default/pages/MyAccount.vue index 80f435aa09..ce7a5953f6 100644 --- a/src/themes/default/pages/MyAccount.vue +++ b/src/themes/default/pages/MyAccount.vue @@ -4,6 +4,7 @@

diff --git a/src/themes/default/pages/Static.vue b/src/themes/default/pages/Static.vue index a06a35d1ed..3f1c35caed 100644 --- a/src/themes/default/pages/Static.vue +++ b/src/themes/default/pages/Static.vue @@ -2,7 +2,7 @@
- +

{{ $props.title }}