关于 Magento 模型和 ORM 基础知识的教程中的模型在 Magento 1.5.0 中不起作用

发布于 2024-10-17 10:40:50 字数 1173 浏览 5 评论 0原文

我也一直在关注这个关于 Magento 模型和 ORM 基础知识的教程。我正在使用 Magento 版本 1.5.0,当我测试模型时发现它是否专门用于打印此代码中的对象,我得到的只是一张空白的白页。

public function testModelAction() {
    $blogpost = Mage::getModel('weblog/blogpost');
    echo get_class($blogpost);
}

我查看了系统日志,发现了这些错误

2011-02-16T04:18:27+00:00 ERR (3): Warning: include(Alanstormdotcom\Weblog\Model\Blogpost.php) [function.include]: failed to open stream: No such file or directory in E:\xampp\htdocs\magento\lib\Varien\Autoload.php on line 94

2011-02-16T04:18:27+00:00 ERR (3): Warning: include() [function.include]: Failed opening 'Alanstormdotcom\Weblog\Model\Blogpost.php' for inclusion (include_path='E:\xampp\htdocs\magento\app\code\local;E:\xampp\htdocs\magento\app\code\community;E:\xampp\htdocs\magento\app\code\core;E:\xampp\htdocs\magento\lib;.;E:\xampp\php\PEAR') in E:\xampp\htdocs\magento\lib\Varien\Autoload.php on line 94

2011-02-16T04:18:27+00:00 ERR (3): Warning: get_class() expects parameter 1 to be object, boolean given in E:\xampp\htdocs\magento\app\code\local\Alanstormdotcom\Weblog\controllers\IndexController.php on line 6

希望你能帮助我解决这个问题..

谢谢..

I've been following this tutorial about Magento's Model and ORM basics too. I'm using Magento Version 1.5.0, and when i came across on testing the model if it works specially in printing the object in this code, all i get is a blank white page.

public function testModelAction() {
    $blogpost = Mage::getModel('weblog/blogpost');
    echo get_class($blogpost);
}

I went to see the system log and i get these errors

2011-02-16T04:18:27+00:00 ERR (3): Warning: include(Alanstormdotcom\Weblog\Model\Blogpost.php) [function.include]: failed to open stream: No such file or directory in E:\xampp\htdocs\magento\lib\Varien\Autoload.php on line 94

2011-02-16T04:18:27+00:00 ERR (3): Warning: include() [function.include]: Failed opening 'Alanstormdotcom\Weblog\Model\Blogpost.php' for inclusion (include_path='E:\xampp\htdocs\magento\app\code\local;E:\xampp\htdocs\magento\app\code\community;E:\xampp\htdocs\magento\app\code\core;E:\xampp\htdocs\magento\lib;.;E:\xampp\php\PEAR') in E:\xampp\htdocs\magento\lib\Varien\Autoload.php on line 94

2011-02-16T04:18:27+00:00 ERR (3): Warning: get_class() expects parameter 1 to be object, boolean given in E:\xampp\htdocs\magento\app\code\local\Alanstormdotcom\Weblog\controllers\IndexController.php on line 6

Hope you can help me in resolving this problem..

Thank you..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笔落惊风雨 2024-10-24 10:40:50

什么样的混蛋会写出不起作用的教程?!

查看错误消息,

2011-02-16T04:18:27+00:00 ERR (3): Warning: include(Alanstormdotcom\Weblog\Model\Blogpost.php) [function.include]: failed to open stream: No such file or directory in E:\xampp\htdocs\magento\lib\Varien\Autoload.php on line 94

Magento 告诉您找不到您的模型文件。您是否创建了名为 Blogpost.php 的模型?它在正确的文件夹中吗?它应该位于

app\code\local\Alanstormdotcom\Weblog\Model\Blogpost.php

如果 Magento 找不到它,则意味着它不存在。如果它在那里,则意味着有人对您的包含路径进行了混淆。

What sort of bum writes a tutorial that doesn't work?!

Take a look at your error message

2011-02-16T04:18:27+00:00 ERR (3): Warning: include(Alanstormdotcom\Weblog\Model\Blogpost.php) [function.include]: failed to open stream: No such file or directory in E:\xampp\htdocs\magento\lib\Varien\Autoload.php on line 94

Magento is telling you it can't find your model file. Have you created the model named Blogpost.php? Is it in the right folder? It should be at

app\code\local\Alanstormdotcom\Weblog\Model\Blogpost.php

If Magento can't find it, that means it's not there. If it is there, than means someone's monkeied with your include path.

生寂 2024-10-24 10:40:50

这是 Alanstormdotcom\Weblog\Model\Blogspot.php

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

这是 config.xml

<config>    
    <modules>
        <Alanstormdotcom_Weblog>
            <version>0.1.0</version>
        </Alanstormdotcom_Weblog>
    </modules>
    <frontend>
        <routers>
            <weblog>
                <use>standard</use>
                <args>
                    <module>Alanstormdotcom_Weblog</module>
                    <frontName>weblog</frontName>
                </args>
            </weblog>
        </routers> 
    </frontend>
    <global>
        <models>
            <weblog>
                <class>Alanstormdotcom_Weblog_Model</class>
                <resourceModel>weblog_mysql4</resourceModel>
            </weblog>
        </models>
    </global>   
</config> 

this the Alanstormdotcom\Weblog\Model\Blogspot.php

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

this is the config.xml

<config>    
    <modules>
        <Alanstormdotcom_Weblog>
            <version>0.1.0</version>
        </Alanstormdotcom_Weblog>
    </modules>
    <frontend>
        <routers>
            <weblog>
                <use>standard</use>
                <args>
                    <module>Alanstormdotcom_Weblog</module>
                    <frontName>weblog</frontName>
                </args>
            </weblog>
        </routers> 
    </frontend>
    <global>
        <models>
            <weblog>
                <class>Alanstormdotcom_Weblog_Model</class>
                <resourceModel>weblog_mysql4</resourceModel>
            </weblog>
        </models>
    </global>   
</config> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文