如何在添加新产品常规标签中添加新字段?

时间:2015-02-04 10:27:10

标签: magento

我正致力于扩展。我需要在添加新产品常规标签中添加新字段。enter image description here

2 个答案:

答案 0 :(得分:1)

使用以下代码为您的扩展程序创建安装脚本:

 $installer = $this;
/* @var $installer Mage_Eav_Model_Entity_Setup */

$installer->startSetup();

$data=array(
    'type'=>'int',
    'input'=>'text', // The type that you want... varchar/boolean...
    'sort_order'=> 1, // YOU MIGHT NEED TO CHANGE THIS VALUE TO PUT THE ATTRIBUTE IN THE FIRST POSITION
    'label'=>'CUSTOM ATTRIBUTE CODE LABEL',
    'global'=>Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'required'=>'0',
    'comparable'=>'0',
    'searchable'=>'0',
    'is_configurable'=>'1',
    'user_defined'=>'1',
    'visible_on_front' => 0, //want to show on frontend?
    'visible_in_advanced_search' => 0,
    'is_html_allowed_on_front' => 0,
    'required'=> 0,
    'unique'=> false,
    'apply_to' => 'configurable', //simple,configurable,bundled,grouped,virtual,downloadable
    'is_configurable' => false
);

$installer->addAttribute('catalog_product','CUSTOM_ATTRIBUTE_CODE',$data);

$installer->addAttributeToSet(
    'catalog_product', 'Default', 'General', 'CUSTOM_ATTRIBUTE_CODE'
); //Default = attribute set, General = attribute group

$installer->endSetup();

致谢:http://ka.lpe.sh/2014/09/04/magento-addremove-product-attribute-programatically/

答案 1 :(得分:1)

For creating attibute you need to follow following steps:

1) Catalog -> Attribute -> Manage Attribute in Magento Admin Panel and Create the attribute which you want to show

2) Catalog -> Attribute -> Manage Attribute Set

3) Select the attribute set name like "DEFAULT"

4) Drag your unassigned attribute to Groups section and click Save Attribute Set

5) Flush Cache

6) Do Reindexing

Thats All you need to do.
相关问题