code for create category attribute


<?php
require_once('app/Mage.php');

Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Sales_Model_Mysql4_Setup;

$attribute  = array(
    'type' => 'text',
    'label'=> 'Call to Action',
    'input' => 'select',
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'visible' => true,
    'required' => false,
    'user_defined' => true,
    'default' => "",
    'option' => array(
        'value' => array('optionone'=> array( 0 =>'Get Product Listing'),'optiontwo'=> array(0 =>'Get Cast Listing') )
        ),
    'group' => "General Information"
);

$installer->addAttribute('catalog_category', 'call_to_action', $attribute);
$installer->endSetup(); 
?>

core for update category attribte


 
<?php
require_once('app/Mage.php');

Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Sales_Model_Mysql4_Setup;

$installer->startSetup();

$aManufacturers = array('Sub Category Listing');
$iProductEntityTypeId = Mage::getModel('catalog/category')->getResource()->getTypeId();
$aOption = array();
$aOption['attribute_id'] = $installer->getAttributeId($iProductEntityTypeId, 'call_to_action');
//echo $aOption['attribute_id']; exit;

for($iCount=0;$iCount<sizeof($aManufacturers);$iCount++){
   $aOption['value']['option'.$iCount][0] = $aManufacturers[$iCount];
}
$installer->addAttributeOption($aOption);

$installer->endSetup(); 
?>
Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.