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());
        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

  • Specify your requirement in details. Aug 14, 2020 at 7:01
  • @DhirenVasoya I have added more details.
    – Arjun
    Aug 14, 2020 at 7:09
  • codes looks ok i think there could be an issue with layout files
    – Pramod
    Aug 14, 2020 at 12:02

1 Answer 1


Try this extension


I think this should satisfy your requirement as it provides a feature to add Mega Menu with navigation type as product's attribute

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.