I am completely new to Magento and have just now installed Magento Community Edition I have created a few product categories from the admin console. I would like to customize the top menu based on some attributes of individual product categories. I have figured out that the changes I need to make will be in a class that overrides Mage_Catalog_Block_Navigation.

The method _renderCategoryMenuItemHtml in this class is invoked with a category. Specifically, I need Is Anchor, Description and Page Title attributes of the category in this method besides the usual ID, name and URL. I can see that the category passed to this method is an instance of Varien_Data_Tree_Node but this instance does not contain the three attributes I need.

I know that I can use the category ID available inside this method to run queries on the database to get the information I need, but I do not want to do this due to performance reasons. I am assuming that there is some code that is fetching category information from the database and is setting that information in Varien_Data_Tree_Node instances. I would like to enhance that code to include the additional attributes I need. However, I have been unable to find that code even after spending 2 days on this.

Can someone point me to the code where I can set the additional attributes in the Varien_Data_Tree_Node instance? Any alternate way of getting category attributes in the Navigation Block would also be helpful, as long as they do not affect performance.


Loading the categories for use in the navigation are done via the function getStoreCategories in the class Mage_Catalog_Block_Navigation:

 * Get catagories of current store
 * @return Varien_Data_Tree_Node_Collection
public function getStoreCategories()
    $helper = Mage::helper('catalog/category');
    return $helper->getStoreCategories();

Here you can see the call to the helper's getStoreCategories function. On looking closer into this function you can provide the following attributes.

$sorted=false, $asCollection=false, $toLoad=true

If you update the call to getStoreCategories add set the second attribute to true then you will get a collection of categories rather than a Varien_Data_Tree_Node_Collection, this collection should contain the fields that you need.

  • I think I had tried this but was still getting Varien_Data_Tree_Node instances. Will try again and report on how it goes. – manish.in.java Apr 7 '14 at 18:00

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.