Created
May 19, 2016 11:53
-
-
Save 0-Sony/585895a5e27aea6a83a109a0212c13c5 to your computer and use it in GitHub Desktop.
Add attributes for categories with installer
This file contains hidden or 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 | |
| try { | |
| /** @var Mage_Catalog_Model_Resource_Setup $installer */ | |
| $installer = $this; | |
| $installer->startSetup(); | |
| $installer->addAttribute( | |
| Mage_Catalog_Model_Category::ENTITY, | |
| 'my_custom_field', | |
| array( | |
| 'group' => 'Display Settings', //it could be also "General Information","Custom Design" | |
| 'type' => 'varchar', | |
| 'label' => 'My Custom Label Field', | |
| 'input' => 'text', | |
| 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, | |
| 'required' => false, | |
| 'visible_on_front' => false, | |
| 'used_in_product_listing' => false, | |
| 'sort_order' => 200, | |
| 'note' => 'add comment here if you want' | |
| ) | |
| ) | |
| ->addAttribute( | |
| Mage_Catalog_Model_Category::ENTITY, | |
| 'my_custom_select', | |
| array( | |
| 'group' => 'General Information', | |
| 'type' => 'text', | |
| 'label' => 'My Custom Select Label', | |
| 'input' => 'select', | |
| 'frontend_class' => '', | |
| 'source' => 'namespace_module/adminhtml_source_category_tree', // get your own adminhtml model | |
| 'backend' => '', | |
| 'frontend' => '', | |
| 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, | |
| 'required' => false, | |
| 'visible_on_front' => false, | |
| 'is_configurable' => false, | |
| 'used_in_product_listing' => false, | |
| 'sort_order' => 150, | |
| 'note' => 'add comment here if you want' | |
| ) | |
| ); | |
| } catch (Exception $e) { | |
| // Silence is golden | |
| Mage::logException($e); | |
| if (Mage::getIsDeveloperMode()) { | |
| Mage::throwException($e->getMessage()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment