Magento 自定义类别属性
我试图在我的magento后端类别中有一个Magento 自定义类别属性,magento,magento-1.4,Magento,Magento 1.4,我试图在我的magento后端类别中有一个multiselect选项 我有以下代码: $installer = $this; $installer->startSetup(); $attribute = array( 'group' => "General Information", // and this one 'label' => 'Location', 'type' => 'varchar',
multiselect
选项
我有以下代码:
$installer = $this;
$installer->startSetup();
$attribute = array(
'group' => "General Information", // and this one
'label' => 'Location',
'type' => 'varchar',
'input' => 'multiselect',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'is_user_defined' => true,
'option'=> array (
'value' => array(
'england'=> array(
0 =>'England'),
'scotland'=> array(
0 =>'Scotland')
)
)
);
$installer->addAttribute('catalog_category', 'bottom_description', $attribute);
$installer->endSetup();
这将在后端创建一个新属性,但没有值
我是否需要配置其他内容以便查看这些值
谢谢
编辑:
在config.xml中,我有:
<version>0.8.0</version>
0.8.0
我有另一个文件:
mysql4-upgrade-0.7.0-0.8.0.php
当我清除缓存并访问类别时,该文件似乎没有运行
有什么想法吗?您在mysql4升级脚本中编写了上述脚本,对吗?是否更新了config.xml版本 因为它仅在config.xml中升级版本时执行
所以请检查一下Arrr….你很接近了。应该是,
'values'=>array(…)
而不是'value'=>array(…)
但我看到了一个问题。向属性添加选项时,选项值应为int值。
假设您在代码中添加了属性,并将产品保存在
位置
英格兰、苏格兰
。数据库中的值不会是英格兰,苏格兰
会是:76,77
。苏格兰和英格兰选项的自动生成ID。如果要将值保存为英格兰、苏格兰,则需要为此属性编写自定义源模型。要在“类别”部分添加自定义“是/否”属性,请创建模块并输入以下代码
也请参考我的教程
是的。每次运行上述命令时,我都会增加版本
0.4.0
,0.5.0
等,并重命名文件mysql4-upgrade-0.0.1-0.4.0.php
,mysql4-upgrade-0.0.1-0.5.php
。但是在清除cacheversion后仍然没有得到任何值,例如升级到mysql4-upgrade-0.4.0-0.5.0.phpAh,这可能就是问题所在。它没有接收到我所做的任何更改检查“核心资源”表找到您的设置条目并检查当前版本当前版本为0.8.0