Categories
Programming

Magento – Adding a Custom Category Attribute (EAV)

[php]
$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);

$setup->startSetup();

$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, ‘show_sale_icon’,
array(
‘backend’ => ”,
‘default’ => 0,
‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
‘group’ => ‘General’,
‘input’ => ‘select’,
‘label’ => ‘Show Category Sale Icon’,
‘position’ => 100,
‘required’ => false,
‘source’ => ‘eav/entity_attribute_source_boolean’,
‘type’ => ‘int’,
‘user_defined’ => true,
‘visible’ => true,
‘visible_on_front’ => true,
)
);

$setup->endSetup();
[/php]

[php]
$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);

$setup->startSetup();

$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, ‘additional_description’,
array(
‘backend’ => ”,
‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
‘group’ => ‘General’,
‘input’ => ‘textarea’,
‘is_html_allowed_on_front’ => true,
‘is_wysiwyg_enabled’ => true,
‘label’ => ‘Additional Description’,
‘position’ => 100,
‘required’ => false,
‘type’ => ‘text’,
‘user_defined’ => true,
‘visible’ => true,
‘visible_on_front’ => true,
)
);

$setup->endSetup();
[/php]

By Kathir Vel

An agile ebusiness & marketing consultant based in Edinburgh, Scotland, UK. ICT specialist with a MBA in marketing and strategy. Seasoned project manager with strong roots in advertising campaigns and film making. Loves photography and travelling.

1 reply on “Magento – Adding a Custom Category Attribute (EAV)”

Leave a Reply

Your email address will not be published. Required fields are marked *