2

I'm working on navigation menu in custom theme Magento web site. I would like to display a list of the specified attribute name (brand) from the specific category. The mentioned navigation menu is on the index/home page.

For example, I have a category name: "Laptops for everyday use", and I have a custom attribute name "brand_name". I would like to be able to display this as:

Laptops for everyday use: - Asus - Acer - Apple etc...

  • is this category attribute? – Amit Bera Jan 18 '15 at 12:12
  • yes, attribute name is "brand_name". This is custom attribute I have made. – user15151 Jan 18 '15 at 12:33
  • is this category type attribute? – Amit Bera Jan 18 '15 at 13:14
1

You can do this by some changes at observer class Mage_Page_Block_Html_Topmenu_Renderer

This class render the menu

Change at Mage_Page_Block_Html_Topmenu_Renderer:

Goto function _addCategoriesToMenu() and here you have find the category name has been set. Find

   $categoryData = array(
        'name' => $category->getName(),
        'id' => $nodeId,
        'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
        'is_active' => $this->_isActiveMenuCategory($category)
    );

Here change at name index

  $categoryData = array(
            'name' => $category->getName().'-'. $category->getData('brand_name'),
            'id' => $nodeId,
            'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
            'is_active' => $this->_isActiveMenuCategory($category)
        );

Note: if $category->getData('brand_name') is not work then try this below code which provide to data from resource model:

$category->getResource()->getAttribute('brand_name')->getFrontend()->getValue($category-)

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.