Search This Blog

Friday 5 July 2013

Adding new / update / delete category attribute in Magento


<?php
/** @var $this Mage_Eav_Model_Entity_Setup */
$this->startSetup();

/** Remove existing atribute */
$this->removeAttribute('catalog_category', 'size_chart');

/** Add new atribute */
$this->addAttribute('catalog_category', 'short_description', array(
    'group'         => 'General Information',
    'input'         => 'textarea',
    'type'          => 'text',
    'label'         => 'Short Description',
    //'source'        => 'categoryattributes/source_sizechart',
    'backend'       => '',
    'visible'       => 1,
    'required'      => 0,
    'user_defined'     => 1,
    'note'             => 'Category Short Description will be shown in bottom  3 boxes of other category pages',
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
/** Update existing atribute */
$categoryEntityTypeId = $this->getEntityTypeId('catalog_category');
$this->updateAttribute($categoryEntityTypeId, 'short_description', 'is_wysiwyg_enabled', 0);
$this->updateAttribute($categoryEntityTypeId, 'short_description', 'is_html_allowed_on_front', 0);

$this->endSetup();

?>
http://www.atwix.com/magento/add-category-attribute/

13 comments:

  1. Thanks. very helpful..

    ReplyDelete
  2. How to create a "date" type custom attribute with datepicker in category ?

    My email: vivek@devrepublic.nl

    ReplyDelete
  3. very informative post...i have a learned some important information in PHP...thank you for sharing the great information..
    Best website developers in bangalore
    Outsource magento ecommerce services india

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Thank you for sharing excellent information. Your website is very cool. Fully useful your blog post... Online Shopping Sites In Ahmedabad

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. I am very glad when I read this blog post
    Thanks for sharing valuable information.
    Keep on posting...

    cloud server india
    domain name reseller
    web hosting india

    ReplyDelete
  9. Thanks for blog posting. Its a Important topic to read..Great Job!, Keep it up..

    design software
    invoicing automation

    ReplyDelete