我想创建三个不同的类别属性,一个自定义输入文本,一个所见即所得文本区域和另一个类别图像上传。
我首先开始使用自定义输入文本,因为我觉得最简单,但它不起作用。我检查了core_resource以查看该版本是否已注册,但它不是该类别的属性。
这是我的代码
应用程序的/ etc /模块/ Rnd_Customheader.xml
<?xml version="1.0"?>
<config>
<modules>
<Rnd_Customheader>
<active>true</active>
<codePool>community</codePool>
</Rnd_Customheader>
</modules>
</config>
应用程序/代码/本地/了Rnd / Customheader /等
<?xml version="1.0"?>
<config>
<modules>
<Rnd_Customheader>
<version>0.1.0</version>
</Rnd_Customheader>
</modules>
<global>
<resources>
<Rnd_Customheader_setup>
<setup>
<module>Rnd_Customheader</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>default_setup</use>
</connection>
</Rnd_Customheader_setup>
</resources>
</global>
</config>
应用程序/代码/本地/了Rnd / Customheader / SQL / rnd_customheader_setup
<?php
$installer = $this;
$installer->startSetup();
$attribute = array(
'type' => 'text',
'label' => 'Custom Header (If you want different page header)',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => "",
'group' => "General Information"
);
$installer->addAttribute('catalog_category', 'custom_header', $attribute);
$installer->endSetup();
?>
这是我的参考资料
https://magento.stackexchange.com/questions/94833/add-custom-attribute-for-category
http://gauss-development.com/blog/tutorials/adding-custom-category-attributes-magento/
我错过了错过的步骤吗?
如果我没错,这个扩展程序会在页面刷新后运行吗?
答案 0 :(得分:0)
尝试以下更改:
<?xml version="1.0"?>
<config>
<modules>
<Rnd_Customheader>
<version>0.1.0</version>
</Rnd_Customheader>
</modules>
<global>
<resources>
<customheader_setup>
<setup>
<module>Rnd_Customheader</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>default_setup</use>
</connection>
</customheader_setup>
</resources>
将 Rnd_Customheader_setup 更改为 customheader_setup 并将dircetory重命名为 app / code / local / Rnd / Customheader / sql / customheader_setup
还要确保安装脚本名称应为 mysql4-install-0.1.0.php ,此处0.1.0是您的模块版本。