@@ -92,9 +92,15 @@ public function getHtml($outermostClass = '', $childrenWrapClass = '', $limit =
92
92
$ this ->getMenu ()->setOutermostClass ($ outermostClass );
93
93
$ this ->getMenu ()->setChildrenWrapClass ($ childrenWrapClass );
94
94
95
- $ transportObject = new DataObject ([
96
- 'html ' => $ this ->_getHtml ($ this ->getMenu (), $ childrenWrapClass , $ limit )
97
- ]);
95
+ $ transportObject = new DataObject (
96
+ [
97
+ 'html ' => $ this ->_getHtml (
98
+ $ this ->getMenu (),
99
+ $ childrenWrapClass ,
100
+ $ limit
101
+ )
102
+ ]
103
+ );
98
104
99
105
$ this ->_eventManager ->dispatch (
100
106
'page_block_html_topmenu_gethtml_after ' ,
@@ -211,8 +217,8 @@ protected function _getHtml(
211
217
$ html = '' ;
212
218
213
219
$ children = $ menuTree ->getChildren ();
214
- $ this ->removeChildrenWithoutActiveParent ($ children );
215
220
$ childLevel = $ this ->getChildLevel ($ menuTree ->getLevel ());
221
+ $ this ->removeChildrenWithoutActiveParent ($ children , $ childLevel );
216
222
217
223
$ counter = 1 ;
218
224
$ childrenCount = $ children ->count ();
@@ -387,14 +393,14 @@ public function getMenu()
387
393
* Remove children from collection when the parent is not active
388
394
*
389
395
* @param Collection $children
390
- *
396
+ * @param int $childLevel
391
397
* @return void
392
398
*/
393
- private function removeChildrenWithoutActiveParent (Collection $ children)
399
+ private function removeChildrenWithoutActiveParent (Collection $ children, int $ childLevel ): void
394
400
{
395
401
/** @var Node $child */
396
402
foreach ($ children as $ child ) {
397
- if ($ child ->getData ('is_parent_active ' ) === false ) {
403
+ if ($ childLevel === 0 && $ child ->getData ('is_parent_active ' ) === false ) {
398
404
$ children ->delete ($ child );
399
405
}
400
406
}
@@ -407,7 +413,7 @@ private function removeChildrenWithoutActiveParent(Collection $children)
407
413
*
408
414
* @return int
409
415
*/
410
- private function getChildLevel ($ parentLevel )
416
+ private function getChildLevel ($ parentLevel ): int
411
417
{
412
418
return $ parentLevel === null ? 0 : $ parentLevel + 1 ;
413
419
}
0 commit comments