>我有一个不可更改的脚本,它不起作用。但是可以在开头或结尾添加代码。
这是脚本:
$installer = $this;
$installer->startSetup();
$installer->setConfigData('general/country/default', 'DE');
$installer->setConfigData('general/country/allow','BE,BG,DK,DE,CY');
$installer->setConfigData('general/country/optional_zip_countries','IE');
$installer->setConfigData('general/country/eu_countries','BE,CY');
$installer->endSetup();
如果我将脚本的开头更改为:
$installer = $this;
$installer = Mage::getModel("eav/entity_setup", "core_setup");
$installer->startSetup();
它会起作用,但正如我所说,它不可能在脚本中编写。我收到的错误是:
Fatal error: Call to a member function startSetup() on a non-object
有没有办法使该脚本正常工作?
它是用于导入系统配置的Magento脚本。
提前谢谢你!
您可以在模块config.xml
中定义安装程序要使用的类(又名$this
),如下所示:
<?xml version="1.0"?>
<config>
<global>
<!--other definitions-->
<resources>
<namespace_module_setup>
<setup>
<module>Namespace_Module</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
</namespace_module_setup>
</resources>
<!--other definitions-->
</global>
<!--other definitions-->
</config>