magento无法加载我的自定义模型

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无法加载该类 我进行了测试,它正在

嗨,我有一个问题,我不明白,请有人能帮我。 我在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无法加载该类

我进行了测试,它正在我的本地机器上工作

请帮忙

另外。我还尝试:


非常感谢。

当您使用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
  • 文件夹和文件名中不应使用下划线

我确实在模块文件夹中添加了一个配置文件。@Manashvibirla你说的表是什么意思?这是whloe模块。只有一个测试模型。检查一下,您可以使用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