Reputation: 107
How to get current custom category attribute value in product list view? I'm trying like this
$attribute = Mage::getModel('catalog/category')->getAttributes();
And I see it's there but how to get it? My custom attribue name is catalog_pdf
Also tryed in this way, but get nothing:
$attribute = Mage::getModel('catalog/category')->getAttribute('catalog_category','catalog_pdf');
Upvotes: 1
Views: 12511
Reputation: 11853
This should work:
$id = $this->getCurrentCategory()->getId();
$category = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getCode()->getId())->load($id);
echo $category->getData('catalog_pdf');
//or
echo $category->getCatalogPdf();
Edited to include missing get
Upvotes: 0
Reputation: 15206
This should work. If you are int the product list then you should have the current category in
Mage::registry('current_category');
So do like this:
$category = Mage::registry('current_category');
if ($category){ //this is necessary in case you are in a product listing that is's not a category
$value = $category->getData('catalog_pdf');//catalog_pdf is the attribute code
//or
//$value = $category->getCatalogPdf();
}
Upvotes: 2