Adding links to top menu in magento

In magento frontend, top menu is fact for customer need. When you add some menu without category then is a fact to add menu. Here I add a menu programmatically with top menu. Following step can add a menu.

Suppose Namespace is “Exercise” and module name is “FrontendMenu” and CodePool is “local”

Step 1: Create a module config file into app/etc/modules/Exercise_FrontendMenu.xml


Step 2: Create a config file under app/code/local/Exercise/FrontendMenu/etc/config.xml


Step 3 : Create a observer into app/code/local/Exercise/FrontendMenu/Model/Observer.php

class Exercise_FrontendMenu_Model_Observer
    public function addToTopmenu(Varien_Event_Observer $observer)
        $menu = $observer->getMenu();
        $tree = $menu->getTree();
        // create a menu tree node
        $node = new Varien_Data_Tree_Node(array(
            'name'   => 'Products',
            'id'     => 'products',
            'url'    => Mage::getUrl('products') // Link url
        ), 'id', $tree, $menu);
        // add node to menu

That’s it! Magento is always beautiful 🙂

One thought on “Adding links to top menu in magento

  1. This is very good hook to add link in top menu, but it’s works only if magento version 1.7+, if I want to add it lower version than this code is not work, could you please help to how should add link in top menu in lower version?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.