How to add custom field/attribute in magento category?
I had searched many times then found good solutions are as follows:-
Create a page in root folder i.e, create-category-attribute.php and paste below code in this page.
$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’); // below code will add text attribute $setup->addAttribute(‘catalog_category’, ‘attribute_code’, array( ‘group’ => ‘General’, ‘input’ => ‘text’, ‘type’ => ‘varchar’, ‘label’ => ‘Attribute label’, ‘backend’ => ”, ‘visible’ => 1, ‘required’ => 0, ‘user_defined’ => 1, ‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, ));</pre> <span style="color: #444444;"> </span> // below code will add yes/no attribute $setup->addAttribute(‘catalog_category’, ‘attribute_code’, array( ‘type’ => ‘int’, ‘label’ => ‘Attribute label’, ‘input’ => ‘select’, ‘source’ => ‘eav/entity_attribute_source_boolean’, ‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, ‘required’ => false, ‘default’ => 1, ‘user_defined’ => 1, ‘default’ => 0 )); // below code will use to add image attribute $setup->addAttribute(‘catalog_category’, ‘attribute_code’, array( ‘group’ => ‘General’, ‘type’ => ‘varchar’, ‘label’ => ‘Attribute Label’, ‘input’ => ‘image’, ‘source’ => ‘eav/entity_attribute_source_boolean’, ‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, ‘required’ => false, ‘backend’ => ‘catalog/category_attribute_backend_image’, ‘frontend_input’ =>”, ‘default’ => 1, ‘visible’ => 1, ‘user_defined’ => 1, ));
‘attribute_code’ will be replace with your own attribute code and same way ‘Attribute Label’ will be replace with attribute label.
Once you run the above script, it will automatically creates attribute.
Then go to admin panel you see a new field added to add category page. Enjoy…..:)
It works nicely in my magento 1.7.