I don't know this is easy to you or not but i need help Please help me

I need a attributes menu in Magento which auto generate

Like admin add 3-4 color and 3-4 size of some product then top menu comes up automatically with 2 menus


And under this drop down user can see which type of color and size available on this store after clicking of any he will show these all products which having this attributes.

if admin add only one extra color/size for any one product this color/size should be on the drop down list.

Thank you I hope you can understand my Question

  • please explain in details or put some screen shot so I will help you – Keyul Shah Jan 3 '14 at 7:44
  • I must say that your question is not very clear, but this sounds just like what the layered navigation does. The only difference is that you want to show it in the top menu. Am I right? – Mark van der Sanden Jan 3 '14 at 8:33
  • Is there any script/program for fetch the attributes On top menu?? – user3040570 Jan 3 '14 at 8:47
  • Sounds like Layered Navigation. It's an inbuilt feature in Magento. Refer this magentocommerce.com/knowledge-base/entry/layered-navigation – Sukeshini Jan 3 '14 at 9:03

There is an explanation on how you can add menu items in the top menu in this question.
You can use the event page_block_html_topmenu_gethtml_before to add menu items to the top menu.
Your observer can look something like this:

public function addItemsToTopmenuItems($observer){
    //get the menu object: //Type Varien_Data_Tree_Node
    $menu = $observer->getMenu();
    //get the tree object in the menu //type Varien_Data_Tree
    $tree = $menu->getTree();
    //get current page handler
    $action = Mage::app()->getFrontController()->getAction()->getFullActionName();
    $colorNodeId = 'color';
    //set the node id, label and url
    $data = array(
        'name' => Mage::helper('catalog')->__('By Color'),
        'id' => $colorNodeId,
        'url' => '#', // no url because there is no page for color
    //create a node object
    $colorNode = new Varien_Data_Tree_Node($data, 'id', $tree, $menu);

    //now create a node for each available color
    $colors = Mage::getModel('eav/config')->getAttribute('catalog_product', 'color')->getSource()->getAllOptions();
    foreach ($colors as $color) {
         $nodeId = 'color-'.$color['value'];
         $data = array(
            'name' => $color['label'], // color label here
            'id' => $nodeId,
            'url' => Mage::getUrl('catalogsearch/advanced/result', array('_query'=>'color='.$color['value'])), // use the advanced search url with a selected color to avoid creating a separate page.
         $node = new Varien_Data_Tree_Node($data, 'id', $tree, $colorNode);
         $colorNode->addChild($node); //add node as submenu for the main color item
    //add the color main node to the menu
    return $this;

I haven't tested the code so you might get some errors, but the idea is the right one. Trust me :).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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