Skip to content

Commit c30e9c6

Browse files
author
Joan He
committed
MAGETWO-72112: [Github] Child categories included in menu when parent category is disabled or hidden #10664
- address code review comments
1 parent f4620b7 commit c30e9c6

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,15 @@ public function beforeGetHtml(
9393
$parentCategoryNode = $mapping[$categoryParentId];
9494

9595
$categoryNode = new Node(
96-
$this->getCategoryAsArray($category, $currentCategory),
96+
$this->getCategoryAsArray(
97+
$category,
98+
$currentCategory,
99+
$category->getParentId() == $categoryParentId
100+
),
97101
'id',
98102
$parentCategoryNode->getTree(),
99103
$parentCategoryNode
100104
);
101-
$categoryNode->setData('is_parent_active', $category->getParentId() == $categoryParentId);
102105
$parentCategoryNode->addChild($categoryNode);
103106

104107
$mapping[$category->getId()] = $categoryNode; //add node in stack
@@ -148,16 +151,18 @@ private function getCurrentCategory()
148151
*
149152
* @param \Magento\Catalog\Model\Category $category
150153
* @param \Magento\Catalog\Model\Category $currentCategory
154+
* @param bool $isParentActive
151155
* @return array
152156
*/
153-
private function getCategoryAsArray($category, $currentCategory)
157+
private function getCategoryAsArray($category, $currentCategory, $isParentActive)
154158
{
155159
return [
156160
'name' => $category->getName(),
157161
'id' => 'category-node-' . $category->getId(),
158162
'url' => $this->catalogCategory->getCategoryUrl($category),
159163
'has_active' => in_array((string)$category->getId(), explode('/', $currentCategory->getPath()), true),
160-
'is_active' => $category->getId() == $currentCategory->getId()
164+
'is_active' => $category->getId() == $currentCategory->getId(),
165+
'is_parent_active' => $isParentActive
161166
];
162167
}
163168

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/SubcategoryNotIncludeInNavigationMenuTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ class SubcategoryNotIncludeInNavigationMenuTest extends Injectable
3737
*
3838
* @var CatalogCategoryIndex
3939
*/
40-
protected $catalogCategoryIndex;
40+
private $catalogCategoryIndex;
4141

4242
/**
4343
* Catalog category edit page.
4444
*
4545
* @var CatalogCategoryEdit
4646
*/
47-
protected $catalogCategoryEdit;
47+
private $catalogCategoryEdit;
4848

4949
/**
5050
* Fixture Factory.
5151
*
5252
* @var FixtureFactory
5353
*/
54-
protected $fixtureFactory;
54+
private $fixtureFactory;
5555

5656
/**
5757
* Inject pages.

0 commit comments

Comments
 (0)