dsfe167834 2013-05-02 13:22
浏览 42
已采纳

在Magento中加载资源模型 - 无法打开文件

I am trying to ues a resource model and get the following when I try to load it:

Warning: include(Mage\Core\Resource\Model.php): failed to open stream: No such file or directory in C:\xampp\htdocs\magento\lib\Varien\Autoload.php on line 93

My controller action looks like:

$blogpost = Mage::getModel("test/blogpost");
$blogpost->load(1);

My config.xml looks like:

<?xml version="1.0"?>
<config>
  <modules>
    <Lock_Test>
      <version>1.0.0</version>
    </Lock_Test>
  </modules>
    <global>
        <models>
            <test>
                <class>Lock_Test_Model</class>
                <resourceModel>test_resource</resourceModel>
            </test>
            <test_resource>
                <class>Lock_Test_Model_Resource</class>
            </test_resource>
        </models>
    </global>
  <frontend>
    <routers>
      <lock_router>
        <use>standard</use>
        <args>
          <module>Lock_Test</module>
          <frontName>test</frontName>
        </args>
      </lock_router>
    </routers>
  </frontend>
</config>

I have no idea why it is trying to load from the Mage directory. I can't see anything wrong with my config file.

I'm loosly following this tutorial, although I haven't created the entities and table name above, I would think it should still find my Resource Model.

Please help!

app\code\local\Lock\Test\Model\Blogpost.php look like:

<?php
    class Lock_Test_Model_Blogpost extends Mage_Core_Model_Abstract
    {
        protected function _construct()
        {
            $this->_init("test/blogpost");
        }
    }

app\code\local\Lock\Test\Model\Resource\Blogpost.php looks like:

<?php
    class Lock_Test_Model_Resource_Blogpost extends Mage_Core_Resource_Model
    {
        protected function _construct()
        {
            $this->_init("test/blogpost", "blogpost_id");
        }
    }
  • 写回答

1条回答 默认 最新

  • dounai6613 2013-05-03 04:48
    关注

    The problem is in your resource model

    class Lock_Test_Model_Resource_Blogpost extends Mage_Core_Resource_Model
    

    There is no such class as Mage_Core_Resource_Model, that is why Magento tries to find him in Mage\Core\Resource\Model.php. What you want to extend from is probably Mage_Core_Model_Resource_Db_Abstract.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置