diff --git a/app/code/Magento/Catalog/Plugin/Block/Topmenu.php b/app/code/Magento/Catalog/Plugin/Block/Topmenu.php index 5119a32d921de..bd56b2e4d8b54 100644 --- a/app/code/Magento/Catalog/Plugin/Block/Topmenu.php +++ b/app/code/Magento/Catalog/Plugin/Block/Topmenu.php @@ -162,6 +162,7 @@ private function getCategoryAsArray($category, $currentCategory, $isParentActive 'url' => $this->catalogCategory->getCategoryUrl($category), 'has_active' => in_array((string)$category->getId(), explode('/', $currentCategory->getPath()), true), 'is_active' => $category->getId() == $currentCategory->getId(), + 'is_category' => true, 'is_parent_active' => $isParentActive ]; } diff --git a/app/code/Magento/Catalog/view/frontend/web/js/product/breadcrumbs.js b/app/code/Magento/Catalog/view/frontend/web/js/product/breadcrumbs.js index b588ac5db7b67..b2755493ec85a 100644 --- a/app/code/Magento/Catalog/view/frontend/web/js/product/breadcrumbs.js +++ b/app/code/Magento/Catalog/view/frontend/web/js/product/breadcrumbs.js @@ -16,6 +16,7 @@ define([ categoryUrlSuffix: '', useCategoryPathInUrl: false, product: '', + categoryItemSelector: '.category-item', menuContainer: '[data-action="navigation"] > ul' }, @@ -166,7 +167,10 @@ define([ categoryMenuItem = null; if (categoryUrl && menu.length) { - categoryMenuItem = menu.find('a[href="' + categoryUrl + '"]'); + categoryMenuItem = menu.find( + this.options.categoryItemSelector + + ' > a[href="' + categoryUrl + '"]' + ); } return categoryMenuItem; diff --git a/app/code/Magento/Theme/Block/Html/Topmenu.php b/app/code/Magento/Theme/Block/Html/Topmenu.php index ed3445e117331..47f88c65acb80 100644 --- a/app/code/Magento/Theme/Block/Html/Topmenu.php +++ b/app/code/Magento/Theme/Block/Html/Topmenu.php @@ -309,6 +309,10 @@ protected function _getMenuItemClasses(\Magento\Framework\Data\Tree\Node $item) $classes[] = 'level' . $item->getLevel(); $classes[] = $item->getPositionClass(); + if ($item->getIsCategory()) { + $classes[] = 'category-item'; + } + if ($item->getIsFirst()) { $classes[] = 'first'; } diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/breadcrumbs.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/breadcrumbs.test.js index 3a41b685229f9..fd787aed067df 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/breadcrumbs.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/breadcrumbs.test.js @@ -20,7 +20,11 @@ define([ }, defaultContext = require.s.contexts._, menuSelector = '[data-action="navigation"] > ul', - menuItem = $('
  • Cat1
  • ')[0], + menuItem = $( + '
  • ' + + 'Cat1' + + '
  • ' + )[0], /** * Create context object.