Search This Blog

Thursday 5 April 2012

Adding And Removing Attributes in Magento


$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$setup->addAttribute('catalog_category', 'author', array(
'group' => 'General',
'input' => 'text',
'type' => 'varchar',
'label' => 'Author',
'backend' => '',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

$setup->addAttribute('catalog_category', 'author_description', array(
'group' => 'General',
'input' => 'textarea',
'type' => 'text',
'label' => 'Author_description',
'backend' => '',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
$setup->addAttribute('catalog_category', 'vendors', array(
'group' => 'General',
'input' => 'select',
'type' => 'varchar',
'label' => 'Vendors',
'backend' => '',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'option' => array ('value' => array('optionone' => array('Sony'),'optiontwo' => array('Samsung'),
'optionthree' => array('Apple'),)),

));

<?php

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->removeAttribute('customer', 'customcode');

?>

No comments:

Post a Comment