Skip to content

Commit a33cd0c

Browse files
committed
MAGETWO-98748: Incorrect behavior in the category menu on the Storefront
- PR stabilization
1 parent c142421 commit a33cd0c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Plugin\Block;
79

810
use Magento\Catalog\Model\Category;
@@ -156,12 +158,13 @@ private function getCurrentCategory()
156158
*/
157159
private function getCategoryAsArray($category, $currentCategory, $isParentActive)
158160
{
161+
$categoryId = $category->getId();
159162
return [
160163
'name' => $category->getName(),
161-
'id' => 'category-node-' . $category->getId(),
164+
'id' => 'category-node-' . $categoryId,
162165
'url' => $this->catalogCategory->getCategoryUrl($category),
163-
'has_active' => in_array((string)$category->getId(), explode('/', $currentCategory->getPath()), true),
164-
'is_active' => $category->getId() == $currentCategory->getId(),
166+
'has_active' => in_array((string)$categoryId, explode('/', (string)$currentCategory->getPath()), true),
167+
'is_active' => $categoryId == $currentCategory->getId(),
165168
'is_category' => true,
166169
'is_parent_active' => $isParentActive
167170
];
@@ -200,6 +203,7 @@ protected function getCategoryTree($storeId, $rootId)
200203
* @param \Magento\Theme\Block\Html\Topmenu $subject
201204
* @param string[] $result
202205
* @return string[]
206+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
203207
*/
204208
public function afterGetCacheKeyInfo(\Magento\Theme\Block\Html\Topmenu $subject, array $result)
205209
{

0 commit comments

Comments
 (0)