I'm trying to add a new field in the Display settings in Manage Categories. I found this tutorial on the web http://www.marketingadept.com/blog/magento-developers-add-a-custom-field-to-the-category-admin-page/
config.xml
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <CmsBlock> <version>0.0.1</version> </CmsBlock> </modules> <global> <resources> <cmsblock_setup> <setup> <module>CmsBlock</module> <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class> <connection> <use>core_setup</use> </connection> </setup> </cmsblock_setup> <cms_block_setup_write> <connection> <use>core_write</use> </connection> </cms_block_setup_write> <cms_block_setup_read> <connection> <use>core_read</use> </connection> </cms_block_setup_read> </resources> </global> </config>
**mysql4-install-0.0.1.php**
$installer = $this; $installer->startSetup(); $entityTypeId = $installer->getEntityTypeId('catalog_category'); $attributeSetId = $installer->getAttributeSetId($entityTypeId); $attributeGroupId = $installer->getAttributeGroupId($entityTypeId, $attributeSetId,5); $installer->addAttribute('catalog_category', 'cms_block', array( 'type' => 'varchar', /* Type - see eav_entity_* for the different types */ 'label' => 'CMS Block', /* Your label */ 'input' => 'select', /* This refers to the type of form field should display*/ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'visible' => TRUE, 'required' => FALSE, 'user_defined' => FALSE, 'option' => array('values'=> array('Option 1','Option 2')) )); $installer->addAttributeToGroup( $entityTypeId, $attributeSetId, $attributeGroupId, 'cms_block', '52' ); $installer->endSetup();
the installer script does run as I checked it in the core_resources table, but the field does not display on the Display Settings Tab. Can anyone help me with this?
Solved! Go to Solution.
Hello janers2015,
1. You add : 'group' => "Display Settings"
$installer->addAttribute('catalog_category', 'cms_block', array(
'type' => 'varchar', /* Type - see eav_entity_* for the different types */
'label' => 'CMS Block', /* Your label */
'input' => 'select', /* This refers to the type of form field should display*/
'global' => Mage_Catalog_Model_Resource_Eav_Attribute:COPE_STORE,
'visible' => TRUE,
'required' => FALSE,
'user_defined' => FALSE,
'option' => array('values'=> array('Option 1','Option 2')),
'group' => 'Display Settings'
));
2. If still not working, you should follow this tutorial: http://www.boolfly.com/create-custom-attributes-in-magento/
If you want the type of input to be dropdown, you change install script by:
<?php $installer = $this; $installer->startSetup(); $attribute = array( 'type' => 'varchar', 'label' => 'CMS Block', 'input' => 'select', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => "", 'option' => array('values'=> array('Option 1','Option 2')), 'group' => "Display Settings" ); $installer->addAttribute('catalog_category', 'external_link', $attribute); $installer->endSetup();
Hello janers2015,
1. You add : 'group' => "Display Settings"
$installer->addAttribute('catalog_category', 'cms_block', array(
'type' => 'varchar', /* Type - see eav_entity_* for the different types */
'label' => 'CMS Block', /* Your label */
'input' => 'select', /* This refers to the type of form field should display*/
'global' => Mage_Catalog_Model_Resource_Eav_Attribute:COPE_STORE,
'visible' => TRUE,
'required' => FALSE,
'user_defined' => FALSE,
'option' => array('values'=> array('Option 1','Option 2')),
'group' => 'Display Settings'
));
2. If still not working, you should follow this tutorial: http://www.boolfly.com/create-custom-attributes-in-magento/
If you want the type of input to be dropdown, you change install script by:
<?php $installer = $this; $installer->startSetup(); $attribute = array( 'type' => 'varchar', 'label' => 'CMS Block', 'input' => 'select', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => "", 'option' => array('values'=> array('Option 1','Option 2')), 'group' => "Display Settings" ); $installer->addAttribute('catalog_category', 'external_link', $attribute); $installer->endSetup();
can u tell me in which file do i have to write this code ?