Magento 如何在“添加新产品常规”选项卡中添加新字段?
我正在办理分机手续。我需要在“添加新产品常规”选项卡中添加新字段 使用以下代码为扩展创建安装脚本:Magento 如何在“添加新产品常规”选项卡中添加新字段?,magento,Magento,我正在办理分机手续。我需要在“添加新产品常规”选项卡中添加新字段 使用以下代码为扩展创建安装脚本: $installer = $this; /* @var $installer Mage_Eav_Model_Entity_Setup */ $installer->startSetup(); $data=array( 'type'=>'int', 'input'=>'text', // The type that you want... varchar/bo
$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();
信用证:这是一个错误…..完整性约束冲突:1452无法添加或更新子行:外键约束失败(
magento
eav\u实体属性
,约束FK\u eav\u实体属性属性
外键(attribute\u ID
)DELET上的REFERENCESeav\u attribute
(attribute\u id
)我将代码包装在startSetup和endSetup中,这应该可以解决问题。你能用更新的代码重试吗?
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.