There are following step
1.Create a new module under your local folder, in our case under /app/local/Bd/Customcategoryattribute.
2.Register the module in etc/modules directory Bd_Customcategoryattribute by using the following code
<?xml version="1.0"?>
<config>
<modules>
<Bd_Customcategoryattribute>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Bd_Customcategoryattribute>
</modules>
</config>
3.Create config.xml under etc directory of your module /app/local/Bd/Customcategoryattribute/etc/config.xml by using the following code
<?xml version="1.0"?>
<config>
<modules>
<Bd_Customcategoryattribute>
<version>0.1.0</version>
</Bd_Customcategoryattribute>
</modules>
<global>
<helpers>
<customcategoryattribute>
<class>Bd_Customcategoryattribute_Helper</class>
</customcategoryattribute>
</helpers>
<models>
<customcategoryattribute>
<class>Bd_Customcategoryattribute_Model</class>
<resourceModel>customcategoryattribute_mysql4</resourceModel>
</customcategoryattribute>
</models>
<resources>
<customcategoryattribute_setup>
<setup>
<module>Bd_Customcategoryattribute</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</customcategoryattribute_setup>
<customcategoryattribute_write>
<connection>
<use>core_write</use>
</connection>
</customcategoryattribute_write>
<customcategoryattribute_read>
<connection>
<use>core_read</use>
</connection>
</customcategoryattribute_read>
</resources>
</global>
</config>
4.Create setup file mysql4-install-0.1.0 under sql directory of your module /app/local/Bd/Customcategoryattribute/sql/customcategoryattribute_setup/mysql4-install-0.1.0.php by using the following code
1.Create a new module under your local folder, in our case under /app/local/Bd/Customcategoryattribute.
2.Register the module in etc/modules directory Bd_Customcategoryattribute by using the following code
<?xml version="1.0"?>
<config>
<modules>
<Bd_Customcategoryattribute>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Bd_Customcategoryattribute>
</modules>
</config>
3.Create config.xml under etc directory of your module /app/local/Bd/Customcategoryattribute/etc/config.xml by using the following code
<?xml version="1.0"?>
<config>
<modules>
<Bd_Customcategoryattribute>
<version>0.1.0</version>
</Bd_Customcategoryattribute>
</modules>
<global>
<helpers>
<customcategoryattribute>
<class>Bd_Customcategoryattribute_Helper</class>
</customcategoryattribute>
</helpers>
<models>
<customcategoryattribute>
<class>Bd_Customcategoryattribute_Model</class>
<resourceModel>customcategoryattribute_mysql4</resourceModel>
</customcategoryattribute>
</models>
<resources>
<customcategoryattribute_setup>
<setup>
<module>Bd_Customcategoryattribute</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</customcategoryattribute_setup>
<customcategoryattribute_write>
<connection>
<use>core_write</use>
</connection>
</customcategoryattribute_write>
<customcategoryattribute_read>
<connection>
<use>core_read</use>
</connection>
</customcategoryattribute_read>
</resources>
</global>
</config>
4.Create setup file mysql4-install-0.1.0 under sql directory of your module /app/local/Bd/Customcategoryattribute/sql/customcategoryattribute_setup/mysql4-install-0.1.0.php by using the following code
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute("catalog_category", "custom_attribute", array(
"type" => "varchar",
"backend" => "",
"frontend" => "",
"label" => "Custom Attribute",
"input" => "text",
"class" => "",
"source" => "",
"global" => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
"visible" => true,
"required" => false,
"user_defined" => false,
"default" => "",
"searchable" => false,
"filterable" => false,
"comparable" => false,
"visible_on_front" => false,
"unique" => false,
"note" => "Extra Attribute"
));
$installer->endSetup();
5. At last create helper Data.php under helper directory of your module /app/local/Bd/Customcategoryattribute/Helper/Data.php by using the following code
<?php
class Bd_Customcategoryattribute_Helper_Data extends Mage_Core_Helper_Abstract
{
}
Here,
type:(realted to db) varchar, text, datetime, int, etc.
input:(reated to frontend filed) text, textarea, date, select, multiselect, select, image
Please comment if u need about other properties. Thanks.
No comments:
Post a Comment