请检查该属性是否出现在您的数据库中,您可以在数据库表 eav_attribute 中的字段 attribute_code 中搜索您的属性名称(例如来自我的下面的文件,它将是 cat_short_description。如果它没有出现在数据库中,那么您的模块设置中有一些错误。
我使用的代码(文件 etc/config.xml):
<?xml version="1.0"?>
<config>
<modules>
<Andreabiedermann_Categoryattributes>
<version>0.0.1</version>
</Andreabiedermann_Categoryattributes>
</modules>
<global>
<resources>
<Categoryattributes_setup>
<setup>
<module>Andreabiedermann_Categoryattributes</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
<connection>
<use>default_setup</use>
</connection>
</Categoryattributes_setup>
</resources>
</global>
</config>
和mysql4-install-0.0.1.php下的sql/Categoryattributes_setup/
$this->startSetup();
$this->addAttribute('catalog_category', 'cat_short_description', array(
'group' => 'General Information',
'input' => 'textarea',
'type' => 'text',
'label' => 'Short Description',
'backend' => '',
'visible' => true,
'required' => false,
'default' => '',
'visible_on_front' => true,
'user_defined' => true,
'is_html_allowed_on_front' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));
$this->endSetup();
请检查 group 是否设置为“常规信息”,如果不是,它将不会出现在类别视图的常规选项卡中。
您可以检查的另一个错误是文件是否具有正确的名称。它应该有正确的版本号。
此外,如果过去有错误并且您想更正它,您需要重新初始化模块的设置过程。为此,请删除 core_resource 表中的模块条目,从后端注销并重新登录。每次您希望安装脚本再次运行时都需要这样做。