diff --git a/app/code/Magento/Theme/Block/Html/Topmenu.php b/app/code/Magento/Theme/Block/Html/Topmenu.php index 37a2149d29809..88ec35c552b44 100644 --- a/app/code/Magento/Theme/Block/Html/Topmenu.php +++ b/app/code/Magento/Theme/Block/Html/Topmenu.php @@ -133,7 +133,7 @@ protected function _countItems($items) * * @param Menu $items * @param int $limit - * @return array|void + * @return array * * @todo: Add Depth Level limit, and better logic for columns */ @@ -141,7 +141,7 @@ protected function _columnBrake($items, $limit) { $total = $this->_countItems($items); if ($total <= $limit) { - return; + return []; } $result[] = ['total' => $total, 'max' => (int)ceil($total / ceil($total / $limit))]; @@ -151,12 +151,9 @@ protected function _columnBrake($items, $limit) foreach ($items as $item) { $place = $this->_countItems($item->getChildren()) + 1; - $count += $place; + $count++; - if ($place >= $limit) { - $colbrake = !$firstCol; - $count = 0; - } elseif ($count >= $limit) { + if ($count > $limit) { $colbrake = !$firstCol; $count = $place; } else { @@ -242,7 +239,7 @@ protected function _getHtml( } if ($this->shouldAddNewColumn($colBrakes, $counter)) { - $html .= '