Hello folks,
If you want to add custom category attribute to Magento then you are at right place.
Today, I am going to show you how to create a custom attribute.
To create a custom attribute the first step is to create a module.
Step 1: Create a file app/code/local/Magemonkeys/Customattribute/etc/config.xml and paste the below code in that file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?xml version="1.0"?> <config> <modules> <Magemonkeys_Customattribute> <version>0.0.1</version> </Magemonkeys_Customattribute> </modules> <global> <resources> <customattribute_setup> <setup> <module>Magemonkeys_Customattribute</module> <class>Mage_Eav_Model_Entity_Setup</class> </setup> <connection> <use>default_setup</use> </connection> </customattribute_setup> </resources> </global> </config> |
Step 2: Create a file app/etc/modules/Magemonkeys_Customattribute.xml and paste the below code in the file
1 2 3 4 5 6 7 8 9 |
<?xml version="1.0"?> <config> <modules> <Magemonkeys_Customattribute> <active>true</active> <codePool>local</codePool> </Magemonkeys_Customattribute> </modules> </config> |
Step 3: Create a file app/code/local/Magemonkeys/Customattribute/sql/customattribute_setup/mysql4-install-0.0.1.php and paste the below code in it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php $installer = $this; $installer->startSetup(); $attribute = array( 'type' => 'text', 'label'=> 'Another Descrtiption', 'input' => 'textarea', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => "", 'group' => "General Information" ); $installer->addAttribute('catalog_category', 'another_description', $attribute); $installer->endSetup(); ?> |
After this you have to clear the cache and go to Catalog -> Manage Categories, you will see your new attribute in the “General Information” tab.
Let us know by making a comment if this article helped you in your Magento development journey.
Update product attribute value programmatically in Magento 2 . [crayon-628775627edbe750745884/]...
If you want restrict customer to checkout based on your...
Sometime we need to set html data without load or...
If you want get query string params in controller file,...
Create di.xml and add the below code Magemonkey/Redirect/etc/frontend/di.xml [crayon-628775627f476576472954/] Create...