I've created an attribute called hero_text_background
in the catalog_category
entity. With this i'm looking to update the frontend_model
property to render some HTML for the frontend.
To test the frontend model works, i've updated the frontend_model
column with the correct class group id in the eav_attribute
table for the attribute. And expected to see the return value for the getValue method i've created in the class.
In my themes catalog/category/view.phtml
i'm calling the attribute from the category object ($_category->getHeroTextBackground()
) this returns the raw attribute value from the database and not through the "frontend model" class.
Do i have to pass my attribute through a method to get the rendered output? Have I configured my attribute wrong?
UPDATE
Original install script, for development i've updated the is_html_allowed_on_front
and backend_model
$installer = Mage::getResourceModel('catalog/setup', 'default_setup');
$installer->startSetup();
$installer->addAttribute(
$installer->getEntityTypeId(Mage_Catalog_Model_Category::ENTITY),
'hero_text_background',
array(
'type' => 'varchar',
'label' => 'Hero Text Background',
'input' => 'select',
'source' => 'bennoislost_heroheaders/catalog_category_attribute_source_hero',
'default' => Bennoislost_HeroHeaders_Model_Catalog_Category_Attribute_Source_Hero::HB_DEFAULT,
'required' => false,
'sort_order' => 0,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'group' => 'Display Settings',
)
);
UPDATE 2
The following snippet indeed call's the correct class:
$_heroTextBackground = Mage::getSingleton('eav/config')
->getAttribute(Mage_Catalog_Model_Category::ENTITY, 'hero_text_background')
->getFrontend()
->getValue($_category);
Is there a nicer way to use this in the template file out of the box?
catalog_category
entity not thecatalog_product
entity – bennoislost Jan 19 '14 at 20:01$_heroTextBackground = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Category::ENTITY, 'hero_text_background')->getFrontend()->getValue($_category);
– bennoislost Jan 19 '14 at 20:22