Add code

Saturday 1 July 2017

How to add custom attribute for category

Follow bellow steps

Step : 1 app\etc\modules\TEJA_Dbchange.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <TEJA_Dbchange>
                <active>true</active>
                <codePool>local</codePool>
            </TEJA_Dbchange>
        </modules>
    </config>

Step : 2 app\code\local\TEJA\Dbchange\etc\config.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <TEJA_Dbchange>
                <version>0.1.0</version>
            </TEJA_Dbchange>
        </modules>
        <global>
            <resources>
                <teja_dbchange_setup>
                  <setup>
                       <module>TEJA_Dbchange</module>
                       <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
                  </setup>
              </teja_dbchange_setup>
            </resources>
        </global>
    </config>

Step : 3 app\code\local\TEJA\Dbchange\sql\teja_dbchange_setup\mysql4-install-0.1.0.php

    <?php
 
    $installer = $this;
    $installer->startSetup();
       
    $attribute  = array(
        'group'                     => 'General',
            'input'                     => 'select',
            'type'                      => 'int',
            'label'                     => 'Testing',
            'source'                    => 'eav/entity_attribute_source_boolean',
            'global'                    => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
            'visible'                   => 1,
            'required'                  => 0,
            'visible_on_front'          => 0,
            'is_html_allowed_on_front'  => 0,
            'is_configurable'           => 0,
            'searchable'                => 0,
            'filterable'                => 0,
            'comparable'                => 0,
            'unique'                    => false,
            'user_defined'              => false,
            'default'           => '0',
            'is_user_defined'           => false,
            'used_in_product_listing'   => true
    );
    $installer->addAttribute('catalog_category', 'testing', $attribute);
    $installer->endSetup();
 
    ?>

Step : 4 After refresh all magento cache by going System -> Cache Management
Step : 5 Logout  and login again.

No comments:

Post a Comment

Magento : 404 error is showing admin page

Hello, Sometimes we may get the error on admin page once done with the Magento installation. In that scenario, we have to do the following: ...