magento无法加载我的自定义模型
嗨,我有一个问题,我不明白,请有人能帮我。 我在1.8.1上 我在app->code->local->Mycompany中有一个模块magento无法加载我的自定义模型,magento,magento-1.8,Magento,Magento 1.8,嗨,我有一个问题,我不明白,请有人能帮我。 我在1.8.1上 我在app->code->local->Mycompany中有一个模块 麦坎帕尼 测试模型 等 config.xml 模型 FirstModel.php config.xml中的代码 0.1.0 Mycompany\u测试模型\u模型 FirstModel.php中的代码 当我使用 Mage::getModel('TestModel/FirstModel') magento无法加载该类 我进行了测试,它正在
- 麦坎帕尼
- 测试模型
- 等
- config.xml
- 模型
- FirstModel.php
- 等
- 测试模型
0.1.0
Mycompany\u测试模型\u模型
FirstModel.php中的代码
当我使用
Mage::getModel('TestModel/FirstModel')
magento无法加载该类
我进行了测试,它正在我的本地机器上工作
请帮忙
另外。我还尝试:
非常感谢。当您使用magento fatory方法时[Mage::getModel('testmodel/FirstModel')] 这意味着您需要使用it过程来定义模型 根据magento,当autoloader执行testmodel/FirstModel时,运行方式如下:
testmodel=Mycompany_TestModel_Model
及
FirsModel错误,文件和名称应为Firstmodel,与model model文件夹(Mycompany/TestModel/model
)后面的一样。所有文件夹和文件名应第一个字母大写,之后的都应为小写
a
这意味着文件应该是
而不是Firstmodel.php
Firstmodel
- 而
应该是testmodel/FirstModel
testmodel/FirstModel
文件夹和文件名中不应使用下划线
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_TestModel>
<version>0.1.0</version>
</Mycompany_TestModel>
</modules>
<global>
<models>
<testmodel> /* instead of <TestModel> */
<class>Mycompany_TestModel_Model</class>
</testmodel>
</models>
</global>
</config>
Mage::getModel('testmodel/FirstModel')
testmodel=Mycompany_TestModel_Model