我在模块设置文件中使用此功能创建了一个属性:
$this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'outofstock_date', array(
'group' => 'Inventory',
'input' => 'text',
'type' => 'int',
'label' => 'Out of Stock Date',
'visible' => 0,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL
));
我知道该属性的创建有效,因为我可以使用此查询在数据库中找到它:
select * from eav_attribute where attribute_code like '%stock%';
但是,我在后端找不到它。它没有出现在编辑产品页面上,我看不到它在属性管理屏幕中列出,也没有在属性集中列出。在创建它时我做错了什么?为什么我不能在后端找到它?
另外:以上是在mysql4-install-0.1.0.php安装文件中,触发它的配置文件部分是这样的:
<resources>
<giftlab_inventory_setup>
<setup>
<module>Giftlab_Inventory</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
</giftlab_inventory_setup>
</resources>
答案 0 :(得分:0)
固定安装程序脚本:
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'outofstock_date', array(
'group' => 'Inventory',
'input' => 'date',
'type' => 'datetime',
'label' => 'Out of Stock Date',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'backend' => 'eav/entity_attribute_backend_datetime',
));
$installer->endSetup();
但是,请注意,小组通常会添加另一个“广告资源”组,因此最终可能会有两个,但由于这个问题是关于后端缺乏可见性,所以答案也是如此。
尝试使用addAttributeToGroup()也许。