Magento Forum

   
Best practice method to create new category attributes
 
jtotheroc
Jr. Member
 
Total Posts:  5
Joined:  2012-01-04
 

Hi,

I have successfully managed to add a custom category attribute with the following code:

<?php
//    initialize magento environment for 'default' store
    
require_once 'app/Mage.php';
    
Mage::app('default');

    echo 
"initialising";
    echo 
runAdd();
    echo 
"finishing";

function 
runAdd()
{
    $setup 
= new Mage_Eav_Model_Entity_Setup('core_setup');
    
// below code will add text attribute
    
$setup->addAttribute('catalog_category''test_field', array(
        
'group'         => 'General',
        
'input'         => 'text',
        
'type'          => 'varchar',
        
'label'         => 'a new text field',
        
'backend'       => '',
        
'visible'       => 1,
        
'required'      => 0,
        
'user_defined'  => 1,
        
'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    ));
}

found here

Can anyone tell me if this is the correct, future proof way of adding a category attribute?

Also if anyone knows, how to delete this attribute too?

Many thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
hkpatel201
Jr. Member
 
Total Posts:  25
Joined:  2013-03-31
 

Try this one

Create new custom category attribute in Magento

Thanks,

 
Magento Community Magento Community
Magento Community
Magento Community
 
jayanta1988
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2012-09-19
 

Hi,

Whatever you did that’s good. You can also see this. Would be interesting.
http://justonestepsolution.blogspot.in/2013/12/how-to-create-custom-category-attribute-in-magento.html
wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
Abhinav Dude
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2010-08-29
Noida, India
 

Yes jtotheroc. You have got a right article on how to add custom attribute to category.

You would also need to play with exceptions handling and fetching the attribute values to the frontend. A nice and detailed article i got from here.

 
Magento Community Magento Community
Magento Community
Magento Community
 
RobertSullivan
Jr. Member
 
Total Posts:  8
Joined:  2014-03-17
 

Check this link,

http://magento.stackexchange.com/questions/648/best-practice-to-display-manufacturer-brand-attribute-several-places

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top