【发布时间】:2015-06-11 13:36:46
【问题描述】:
我在 magento 1.9.1 中创建模块,为类别创建属性。我创建了如下文件:
app\etc\modules\Ddevs_Ebayaff.xml
<?xml version="1.0"?>
<config>
<modules>
<Ddevs_Ebayaff>
<active>true</active>
<codePool>local</codePool>
</Ddevs_Ebayaff>
</modules>
</config>
我正在尝试在一个配置文件中调用控制器和 mysql 安装脚本,如下所示
app\code\local\Ddevs\Ebayaff\etc\config.xml
<?xml version="1.0"?> <config>
<modules>
<ddevs_ebayaff>
<version>
0.1.0
</version>
</ddevs_ebayaff>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Ddevs_Ebayaff</module>
<frontName>ebayaffload</frontName>
</args>
</helloworld>
</routers>
</frontend>
<global>
<resources>
<add_category_attribute>
<setup>
<module>Ddevs_Ebayaff</module>
<class>Mage_Catalog_Model_Resource_Setup</class>
</setup>
</add_category_attribute>
</resources>
</global>
</config>
在IndexController中,我有以下内容
app\code\local\Ddevs\Ebayaff\controllers\IndexController.php
<?php
class Ddevs_Ebayaff_IndexController extends Mage_Core_Controller_Front_Action{
public function indexAction(){
$this->loadLayout();
$this->renderLayout();
}
}
而我的安装脚本如下:
app\code\local\Ddevs\Ebayaff\sql\add_category_attribute\mysql4-install-0.1.0.php
<?php
$this->startSetup();
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'ddev_ebayaff_cat', array(
'group' => 'General Information',
'input' => 'text',
'type' => 'text',
'label' => 'Category ID',
'backend' => '',
'visible' => true,
'required' => false,
'visible_on_front' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
$this->endSetup();
【问题讨论】:
-
如果人们来这里寻找答案,Magento StackExchange 上有很多相同的问题:magento.stackexchange.com/questions/70744/…