Develo Design


Showing Products in a Magento Mega Menu

It can be difficult finding creative ways to promote products on your ecommerce site, I’m sure most retailers would benefit from pushing sales of certain products. Trying to do this while keeping a site easily to navigate is sometimes difficult, I was recently asked to implement featured products into the drop down menu of a Magento site. Magento’s menu generating code is pretty straight forward and with a bit of careful coding you can insert some extra markup in the right places to allow a different product to be shown in each dropdown area.

The following code adds a product as an additional <li> element in the subcategory <ul>’s, then with a bit of css you can style it as required. View the code in action at

 Some fairly technical code is about to follow. If you would prefer to stay away from the code but want this feature implemented on your site, send us a message and see what we can do for you.

Add The following function at the bottom of app/code/local/Mage/Catalog/Block/Navigation.php

If this file doesn’t exist then copy your app/code/core/Mage/Catalog/Block/Navigation.php file to the local code pool. Note that some themes may already be over-riding this file as I found with the GravDept Acumen template.

This function is then called within template/catalog/navigation/top.phtml,

The featured product is then inserted into the menu code within the last

    that’s generated by the standard Magento function. The Menu on this site also contains a ‘Sale’ category that doesn’t have a drop down, so I had to add add an additional check for $_category->getName() !== ‘SALE’.

The product is then styled with CSS to be positioned right and not interfere with the main menu links.

  There are a number of different ways to approach the product selection and assignment to the specific menus. I chose to add a new product attribute which indicates if the product should be featured in the ‘featured menu position’. Once selected it’s added to a list and a random product is chosen to be displayed from this list.
The drawbacks of this method are that it’s not possible to see what products have this attribute enabled without going into each product and it’s not possible to select specific products for a specific menu. If I had more time then I’d investigate adding a product selector to the category pages so you could assign it there, or do a custom module that allows a product category mapping to be created.


Loading Disqus Comments ...
Loading Facebook Comments ...

Post Comment

Your email address will not be published. Required fields are marked *

Discuss My Project

We want to hear about your project! Provide us with a few details and we’ll get back to you for a chat.