diff --git a/CHANGELOG.md b/CHANGELOG.md index 521a1d1652..fa2e52b4c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added validation message for city field on checkout page - @dz3n (#3723) - Make price calculation based on saved original prices - @gibkigonzo (#3740) - Improving is_comparable to work with booleans and digits - @dz3n (#3697) +- Fixed displaying categories on search menu - @andrzejewsky (#3758) - Fixed broken link for store locator - @andrzejewsky (#3754) - Fixed instant checkout functionality - @andrzejewsky (#3765) - Fixed links to the promoted banners - @andrzejewsky (#3753) diff --git a/src/themes/default/components/core/blocks/SearchPanel/SearchPanel.vue b/src/themes/default/components/core/blocks/SearchPanel/SearchPanel.vue index 12e37fbc87..342a9d3ec8 100644 --- a/src/themes/default/components/core/blocks/SearchPanel/SearchPanel.vue +++ b/src/themes/default/components/core/blocks/SearchPanel/SearchPanel.vue @@ -113,13 +113,16 @@ export default { return productList }, categories () { - const categoriesMap = {} - this.products.forEach(product => { - [...product.category].forEach(category => { - categoriesMap[category.category_id] = category - }) - }) - return Object.keys(categoriesMap).map(categoryId => categoriesMap[categoryId]) + const categories = this.products + .filter(p => p.category) + .map(p => p.category) + .flat() + + const discinctCategories = Array.from( + new Set(categories.map(c => c.category_id)) + ).map(catId => categories.find(c => c.category_id === catId)) + + return discinctCategories }, getNoResultsMessage () { let msg = ''