Skip to content

Commit c7e5d36

Browse files
author
Michail Slabko
committed
Merge commit 'refs/pull/1083/head' of https://github.com/magento/magento2 into MAGETWO-34954-github
2 parents 8b8cd0b + a03c9ad commit c7e5d36

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

app/code/Magento/Catalog/Model/Observer.php

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,12 @@ protected function _addCategoriesToMenu($categories, $parentCategoryNode, $block
132132
continue;
133133
}
134134

135-
$nodeId = 'category-node-' . $category->getId();
136-
137135
$block->addIdentity(\Magento\Catalog\Model\Category::CACHE_TAG . '_' . $category->getId());
138136

139137
$tree = $parentCategoryNode->getTree();
140-
$categoryData = [
141-
'name' => $category->getName(),
142-
'id' => $nodeId,
143-
'url' => $this->_catalogCategory->getCategoryUrl($category),
144-
'is_active' => $this->_isActiveMenuCategory($category),
145-
];
138+
139+
$categoryData = $this->getMenuCategoryData($category);
140+
146141
$categoryNode = new \Magento\Framework\Data\Tree\Node($categoryData, 'id', $tree, $parentCategoryNode);
147142
$parentCategoryNode->addChild($categoryNode);
148143

@@ -156,6 +151,28 @@ protected function _addCategoriesToMenu($categories, $parentCategoryNode, $block
156151
}
157152
}
158153

154+
155+
/**
156+
* Get category data to be added to the Menu
157+
*
158+
* @param \Magento\Framework\Data\Tree\Node $category
159+
* @return array
160+
*/
161+
public function getMenuCategoryData($category)
162+
{
163+
164+
$nodeId = 'category-node-' . $category->getId();
165+
166+
$categoryData = [
167+
'name' => $category->getName(),
168+
'id' => $nodeId,
169+
'url' => $this->_catalogCategory->getCategoryUrl($category),
170+
'is_active' => $this->_isActiveMenuCategory($category),
171+
];
172+
173+
return $categoryData;
174+
}
175+
159176
/**
160177
* Checks whether category belongs to active category's path
161178
*

0 commit comments

Comments
 (0)