Magento adding attribut using install script

泪湿孤枕 提交于 2019-12-01 11:25:37
try 

<?php

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();


$installer->addAttributeGroup('catalog_product', 'Default', 'Prices', 1000);
$installer->addAttribute('catalog_product', 'custom_price', array(
        'group'             => 'Prices',
        'label'                => 'Apply Custom price',
        'type'                => 'int',
        'input'                => 'boolean',
        'source'               => 'eav/entity_attribute_source_boolean',
        'global'               => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
        'visible'              => 1,
        'required'             => 1,
        'user_defined'         => 1,
        'searchable'           => 0,
        'filterable'           => 0,
        'comparable'           => 0,
        'visible_on_front'     => 0,
        'visible_in_advanced_search'    => 0,
        'unique'            => 0,
        'default'            => 0
));

$setup->updateAttribute('catalog_product', 'custom_price', 'is_used_for_promo_rules',1);
$setup->updateAttribute('catalog_product', 'custom_price', 'is_used_for_price_rules',1);
$installer->endSetup(); 

i think you forgot to define Attribute Group for your attribute.

hope this help

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!