I am trying to get the page_title (custom category attribute) in Navigation.php (menu build up) to use as the html title attribute.

For example this is were we would use the extra attribute in an html ahref title attribute: https://github.com/OpenMage/magento-lts/blob/1.9.3.x/app/code/core/Mage/Catalog/Block/Navigation.php#L308

We added this code, but it is not retrieving the page_title custom attribute

        $page_title = $this->escapeHtml($category->getPageTitle());
        if (empty($page_title)) {
            $page_title = $this->escapeHtml($category->getName());

But $category->getPageTitle() is not returning anything


How can we get the page_title attribute directly?


The category collection doesn't load all attributes of a category by default. That would be a performance issue as well as loading each category separately in the navigation loop.

I think the best way to get a custom attribute of a category for using it in the navigation is to overwrite the category ressource model Mage_Catalog_Model_Resource_Category and add your custom attribute to the the fields returned by the collection in getChildrenCategories($category) method:

public function getChildrenCategories($category)
    $collection = $this->_getChildrenCategoriesBase($category);
    $collection->addAttributeToFilter('is_active', 1)

    return $collection;

Not tested ... but it shoud work to add custom attributes here: https://github.com/OpenMage/magento-lts/blob/1.9.3.x/app/code/core/Mage/Catalog/etc/config.xml#L776-L784


(put it into own module of course ;) )

  • Thx! I fixed it adding the data as below "addAttributeToSelect" in getChildrenCategories ... but would this solution have the same result?
    – snh_nl
    Sep 3 '20 at 14:31
  • @snh_nl yes, it should have the same result. As said, i've not tested it. Can you give it a try?
    – sv3n
    Sep 3 '20 at 14:37

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.