Showing posts with label How to add custom field in category magento. Show all posts
Showing posts with label How to add custom field in category magento. Show all posts

Tuesday, 29 September 2015

How to add custom field or attribute in category magento backend


How to add custom field or attribute in category magento backend

Here i have make a module for add custom field/attribute in category. In my module example user can add thumbnail link in category. In additional you can also create your own attribute from my example module. So now lets start for module.

First of all create Setblue_Chand.xml file and save it to app/etc/modules/Setblue_Chand.xml and paste below code :

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


Next up, lets create another XML file Config.xml and save it to  app/code/local/Setblue/Chand/etc/config.xml and paste below code :

<?xml version="1.0"?>
<config>
  <modules>
    <Setblue_Chand>
      <version>0.0.1</version>
    </Setblue_Chand>
  </modules>
    <global>
      <resources>
          <customlink_setup>
            <setup>
              <module>Setblue_Chand</module>
              <class>Mage_Eav_Model_Entity_Setup</class>
            </setup>
            <connection>
              <use>default_setup</use>
            </connection>
          </customlink_setup>
      </resources>
    </global>
</config>

Now create mysql4-install-0.0.1.php file and save it to app/code/local/Setblue/Chand/sql/customlink_setup/mysql4-install-0.0.1.php and paste below code :

<?php
    $installer = $this;
    $installer->startSetup();
    $attribute  = array(
        'type' => 'text',
        'label'=> 'Thumbnail Link',
        'input' => 'text',
        'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
        'visible' => true,
        'required' => false,
        'user_defined' => true,
        'default' => "",
        'group' => "General Information",
        'sort_order' => 6
    );
    $installer->addAttribute('catalog_category', 'thumbnail_link', $attribute);
 
    $installer->endSetup();
?>

Note: If above module already install in your site then delete the module entry from core_resources table and check.

That's it. Now clear your cache and check the General Information in category in admin panel. The page should look like this :