[英]Loading a resource model in Magento- failed to open file
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: 我的
config.xml
看起来像:
<?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. 我不知道为什么它试图从
Mage
目录加载。 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: app\\code\\local\\Lock\\Test\\Model\\Blogpost.php
看起来像:
<?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: app\\code\\local\\Lock\\Test\\Model\\Resource\\Blogpost.php
如下所示:
<?php
class Lock_Test_Model_Resource_Blogpost extends Mage_Core_Resource_Model
{
protected function _construct()
{
$this->_init("test/blogpost", "blogpost_id");
}
}
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. 没有像Mage_Core_Resource_Model这样的类,这就是Magento试图在Mage \\ Core \\ Resource \\ Model.php中找到他的原因。 What you want to extend from is probably Mage_Core_Model_Resource_Db_Abstract .
你想要扩展的可能是Mage_Core_Model_Resource_Db_Abstract 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.