I've created a custom extension in order to add a custom attribute on product Categories. Here's the code I've used to create it:
$installer = $this;
$installer->startSetup();
$attribute = array(
'type' => 'int',
'label'=> 'Featured Author',
'input' => 'checkbox',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => 0,
'source' => "eav/entity_attribute_source_boolean",
'group' => "General Information"
);
$installer->addAttribute('catalog_category', 'featured_author', $attribute);
$installer->endSetup();
The attribute is created and it's visible on backend. I also checked eav_attribute database table and the attribute is created in there too.
But changing the attribute's value (check/uncheck) and then saving category has no effect at all. The attribute value is not updated/saved. The checkbox is always unchecked.
What should I do to fix this?
catalog_category_entity_int
? As a general advice. Try to avoid checkboxes and radio buttons in the backend forms. They don't play well with Magento. Use instead a yes/no attribute and have a dropdown. The problem with checkboxes is that the value is not sent when the checkbox is unchecked. With selects you will have the value 0.