@@ -132,17 +132,12 @@ protected function _addCategoriesToMenu($categories, $parentCategoryNode, $block
132
132
continue ;
133
133
}
134
134
135
- $ nodeId = 'category-node- ' . $ category ->getId ();
136
-
137
135
$ block ->addIdentity (\Magento \Catalog \Model \Category::CACHE_TAG . '_ ' . $ category ->getId ());
138
136
139
137
$ 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
+
146
141
$ categoryNode = new \Magento \Framework \Data \Tree \Node ($ categoryData , 'id ' , $ tree , $ parentCategoryNode );
147
142
$ parentCategoryNode ->addChild ($ categoryNode );
148
143
@@ -156,6 +151,28 @@ protected function _addCategoriesToMenu($categories, $parentCategoryNode, $block
156
151
}
157
152
}
158
153
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
+
159
176
/**
160
177
* Checks whether category belongs to active category's path
161
178
*
0 commit comments