I need to add submenu in top navigation menu
I am using below code but it is adding in top & not sub menu.
$menu = $observer->getMenu();
$tree = $menu->getTree();
$data = [
'name' => __('Menu item label here'),
'id' => 'some-unique-id-here',
'url' => 'url goes here',
'has_active' => false,
'is_active' => false //
];
$node = new Node($data, 'id', $tree, $menu);
foreach ($menu->getChildren() as $node) {
if ($node->getName() == 'Carpet') {
// echo "<pre>";
// print_r($node->getId());
}
}
//die();
$menu->addChild($node);
return $this;
I want to add submenu based on condition like for 1 top menu category I want to add 1 link e.g. color & 2nd link in another top menu category e.g. size
I have a category top navigation menu by default of magento. Now I need to add color filter for each menu item.
For e.g. Shoes is the main menu & when we hover shoes it should display colors like White, black etc.. & on click of white I want to add redirection URL of filter. So in short white will be like a submenu