gpt4 book ai didi

Magento getModel 返回 false

转载 作者:行者123 更新时间:2023-12-02 01:48:43 26 4
gpt4 key购买 nike

我阅读并关注了 this guide

但是这个错误:

Fatal error: Call to a member function load() on a non-object in C:\wamp\www\Ishop\app\code\core\Mage\Core\Model\Abstract.php on line 225

这是config.xml

<models>
<weblog>
<class>Magentotutorial_Weblog_Model</class>
<resourceModel>weblog_resource</resourceModel>
</weblog>
<weblog_resource>
<class>Magentotutorial_Weblog_Model_Resource</class>
<entities>
<blogpost>
<table>blog_posts</table>
</blogpost>
</entities>
</weblog_resource>
</models>

我添加了名为 blog_posts 的表。我是 Magento 的新手。是调试这个问题的方法吗?我认为 config.xml 文件中有错误。但是我检查了几次,还是没有发现错误。

最佳答案

您的某个模型似乎有问题。

你应该有一个文件 app/code/local/Magentotutorial/Weblog/Model/Blogpost.php:

<?php
class Magentotutorial_Weblog_Model_Blogpost extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init('weblog/blogpost');
}
}
?>

还有一个文件 app/code/local/Magentotutorial/Weblog/Model/Resource/Blogpost.php:

<?php
class Magentotutorial_Weblog_Model_Resource_Blogpost extends Mage_Core_Model_Resource_Db_Abstract{
protected function _construct()
{
$this->_init('weblog/blogpost', 'blogpost_id');
}
}
?>

还有一个文件 app/code/local/Magentotutorial/Weblog/Model/Resource/Blogpost/Collection.php:

<?php
class Magentotutorial_Weblog_Model_Resource_Blogpost_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
protected function _construct()
{
$this->_init('weblog/blogpost');
}
}
?>

关于Magento getModel 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24053672/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com