Skip to content

Commit 9b886a7

Browse files
author
Joan He
committed
MAGETWO-72112: [Github] Child categories included in menu when parent category is disabled or hidden #10664
1 parent f757b46 commit 9b886a7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function beforeGetHtml(
9898
$parentCategoryNode->getTree(),
9999
$parentCategoryNode
100100
);
101+
$categoryNode->setData('is_parent_active', $category->getParentId() == $categoryParentId);
101102
$parentCategoryNode->addChild($categoryNode);
102103

103104
$mapping[$category->getId()] = $categoryNode; //add node in stack

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ protected function _getHtml(
220220
$parentPositionClass = $menuTree->getPositionClass();
221221
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
222222

223+
/** @var \Magento\Framework\Data\Tree\Node $child */
223224
foreach ($children as $child) {
225+
if ($childLevel === 0 && $child->getData('is_parent_active') === false) {
226+
continue;
227+
}
224228
$child->setLevel($childLevel);
225229
$child->setIsFirst($counter == 1);
226230
$child->setIsLast($counter == $childrenCount);

0 commit comments

Comments
 (0)