Created
October 20, 2017 11:21
-
-
Save vkathirvel/cfc5ec152ab8924e4bcd2c24aa390d7c to your computer and use it in GitHub Desktop.
Magento Add Category Attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('app/Mage.php'); //Path to Magento | |
umask(0); | |
Mage::app(); | |
$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); | |
$setup->startSetup(); | |
$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'secondary_heading', | |
array( | |
'backend' => '', | |
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, | |
'group' => 'Custom Fields', | |
'input' => 'text', | |
'is_html_allowed_on_front' => true, | |
'is_wysiwyg_enabled' => false, | |
'label' => 'Secondary Heading', | |
'position' => 100, | |
'required' => false, | |
'type' => 'varchar', | |
'user_defined' => true, | |
'visible' => true, | |
'visible_on_front' => true, | |
) | |
); | |
$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'secondary_description', | |
array( | |
'backend' => '', | |
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, | |
'group' => 'Custom Fields', | |
'input' => 'textarea', | |
'is_html_allowed_on_front' => 1, | |
'is_wysiwyg_enabled' => 1, | |
'label' => 'Secondary Description', | |
'position' => 101, | |
'required' => false, | |
'type' => 'text', | |
'user_defined' => true, | |
'visible' => true, | |
'visible_on_front' => true, | |
) | |
); | |
$setup->endSetup(); | |
// Go to the database catalog_eav_attribute - find the attribute (most likely the last one) and set is_html_allowed_on_front and is_wysiwyg_enabled to 1 | |
$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'partner_category', | |
array( | |
'backend' => '', | |
'default' => 0, | |
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, | |
'group' => 'Custom Fields', | |
'input' => 'select', | |
'label' => 'Is partner category?', | |
'position' => 102, | |
'required' => false, | |
'source' => 'eav/entity_attribute_source_boolean', | |
'type' => 'int', | |
'user_defined' => true, | |
'visible' => true, | |
'visible_on_front' => true, | |
) | |
); | |
$setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'partner_logo', | |
array( | |
'backend' => 'catalog/category_attribute_backend_image', | |
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, | |
'group' => 'Custom Fields', | |
'input' => 'image', | |
'is_html_allowed_on_front' => 1, | |
'is_wysiwyg_enabled' => 1, | |
'label' => 'Partner Logo', | |
'position' => 103, | |
'required' => false, | |
'type' => 'varchar', | |
'user_defined' => true, | |
'visible' => true, | |
'visible_on_front' => true, | |
) | |
); | |
$setup->endSetup(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment