Magento 1.9 Custom Category – Get Custom Attribute Value

categorycustom-attributeseavmagento-1.9

I have created a custom category attribute using this tutorial http://gauss-development.com/blog/tutorials/adding-custom-category-attributes-magento/.

<?php
$installer = $this;
$installer->startSetup();
$attribute  = array(
    'type'          =>  'text',
    'label'         =>  'Extra Title',
    'input'         =>  'text',
    'global'        =>  Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible'       =>  true,
    'required'      =>  false,
    'user_defined'  =>  true,
    'default'       =>  "",
    'group'         =>  "General Information"
);
$installer->addAttribute('catalog_category', 'cat_extra_title', $attribute);
$installer->endSetup();
?>

I have checked that the attribute is stored in eav_attribute table normally, but I can't get it's value.

$category = Mage::registry('current_category');
if ($category){
   $value = $category->getData('cat_extra_title'); //value is empty
}

Any ideas?

Best Answer

After testing many possible solutions, this was the only one that worked for me:

$cat_extra_title = Mage::getModel('catalog/category')->load($category->getId())->getData('cat_extra_title');
Related Topic