我在magento 1.9.1中创建模块,为类别创建属性。我创建了如下文件:
应用\等\模块\ Ddevs_Ebayaff.xml
<?xml version="1.0"?>
<config>
<modules>
<Ddevs_Ebayaff>
<active>true</active>
<codePool>local</codePool>
</Ddevs_Ebayaff>
</modules>
</config>
我试图在一个配置文件中调用控制器和mysql安装脚本,如下所示
应用\代码\本地\ Ddevs \ Ebayaff \等\ 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中,我有以下内容
应用\代码\本地\ Ddevs \ Ebayaff \控制器\ IndexController.php
<?php
class Ddevs_Ebayaff_IndexController extends Mage_Core_Controller_Front_Action{
public function indexAction(){
$this->loadLayout();
$this->renderLayout();
}
}
我的安装脚本如下:
应用\代码\本地\ Ddevs \ Ebayaff \ SQL \ add_category_attribute \ mysql4安装-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();
答案 0 :(得分:1)
首先在config.xml中进行以下更改
<modules>
<Ddevs_Ebayaff>
<version>
0.1.0
</version>
</Ddevs_Ebayaff>
</modules>
<models>
<modulename>
<class>NameSpace_ModuleName_Model</class>
<resourceModel>modulename_mysql4</resourceModel>
</modulename>
</models>
<resources>
<category_setup>
<setup>
<module>NameSpace_ModuleName</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</category_setup>
<category_write>
<connection>
<use>core_write</use>
</connection>
</category_write>
<category_read>
<connection>
<use>core_read</use>
</connection>
</category_read>
</resources>
答案 1 :(得分:0)
<add_category_attribute>
<setup>
<module>Ddevs_Ebayaff</module>
<class>Mage_Catalog_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</add_category_attribute>