Skip to content

Commit 6ebbc45

Browse files
ENGCOM-1444: Prevent double home links in breadcrumbs at product page #14994
- Merge Pull Request #14994 from vovayatsyuk/magento2:fix-double-home-breadcrumbs - Merged commits: 1. b0a14be 2. fa250f5 3. e69335c 4. 1df8452 5. 384c804 6. 5a45084
2 parents 5ed3aa3 + 5a45084 commit 6ebbc45

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

app/code/Magento/Catalog/Plugin/Block/Topmenu.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ private function getCategoryAsArray($category, $currentCategory, $isParentActive
162162
'url' => $this->catalogCategory->getCategoryUrl($category),
163163
'has_active' => in_array((string)$category->getId(), explode('/', $currentCategory->getPath()), true),
164164
'is_active' => $category->getId() == $currentCategory->getId(),
165+
'is_category' => true,
165166
'is_parent_active' => $isParentActive
166167
];
167168
}

app/code/Magento/Catalog/view/frontend/web/js/product/breadcrumbs.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ define([
1616
categoryUrlSuffix: '',
1717
useCategoryPathInUrl: false,
1818
product: '',
19+
categoryItemSelector: '.category-item',
1920
menuContainer: '[data-action="navigation"] > ul'
2021
},
2122

@@ -166,7 +167,10 @@ define([
166167
categoryMenuItem = null;
167168

168169
if (categoryUrl && menu.length) {
169-
categoryMenuItem = menu.find('a[href="' + categoryUrl + '"]');
170+
categoryMenuItem = menu.find(
171+
this.options.categoryItemSelector +
172+
' > a[href="' + categoryUrl + '"]'
173+
);
170174
}
171175

172176
return categoryMenuItem;

app/code/Magento/Theme/Block/Html/Topmenu.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ protected function _getMenuItemClasses(\Magento\Framework\Data\Tree\Node $item)
309309
$classes[] = 'level' . $item->getLevel();
310310
$classes[] = $item->getPositionClass();
311311

312+
if ($item->getIsCategory()) {
313+
$classes[] = 'category-item';
314+
}
315+
312316
if ($item->getIsFirst()) {
313317
$classes[] = 'first';
314318
}

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/breadcrumbs.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ define([
2020
},
2121
defaultContext = require.s.contexts._,
2222
menuSelector = '[data-action="navigation"] > ul',
23-
menuItem = $('<li class="level0"><a href="http://localhost.com/cat1.html" id="ui-id-3">Cat1</a></li>')[0],
23+
menuItem = $(
24+
'<li class="level0 category-item">' +
25+
'<a href="http://localhost.com/cat1.html" id="ui-id-3">Cat1</a>' +
26+
'</li>'
27+
)[0],
2428

2529
/**
2630
* Create context object.

0 commit comments

Comments
 (0)