In this class app/code/core/Mage/Catalog/Block/Navigation.php
in this method:
/**
* Render category to html
*
* @param Mage_Catalog_Model_Category $category
* @param int Nesting level number
* @param boolean Whether ot not this item is last, affects list item class
* @param boolean Whether ot not this item is first, affects list item class
* @param boolean Whether ot not this item is outermost, affects list item class
* @param string Extra class of outermost list items
* @param string If specified wraps children list in div with this class
* @param boolean Whether ot not to add on* attributes to list item
* @return string
*/
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
{
if (!$category->getIsActive()) {
return '';
}
//...
}
the first parameter $category
has type Mage_Catalog_Model_Category
. I need to get the value of the custom category attribute inside that method. But when I try to get the category attribute value like this:
$value = $category->getData('catalog_pdf');
it returns nothing. I checked the type of the parameter $category
with
get_class($category); //It returnes Varien_Data_Tree_Node
and it turned out to be Varien_Data_Tree_Node
(but not Mage_Catalog_Model_Category
like it is declared in the comments above this method).
So my question is:
-
How I can retrieve an object of type
Mage_Catalog_Model_Category
so that it is possible to retrieve value of the category attribute? Is the standard category object wrapped somehow inside that object of typeVarien_Data_Tree_Node
? -
And a bonus question: what is that type
Varien_Data_Tree_Node
used for? I tried to investigate the code but that class seems to be quite complicated. If anyone knows any good tutorials about it, I'd be very grateful.
Best Answer
Try something like that:
EDIT:
Better way (without loading whole category model):