Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento getModel return false

Tags:

magento

I read and following this guide

But this error :

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

this is 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>

I added table with name is blog_posts. I am a newbie with Magento. Is the way to debug this issue? I think error in config.xml file. but I review it several times, still don't find error.

like image 863
user3541964 Avatar asked Sep 16 '26 09:09

user3541964


1 Answers

It seems like there's a problem within one of your models.

You should have a file 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');
        }
    }
?>

And a file 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');
        }
    } 
?>

And a file 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');
        }
    }
?>
like image 96
Gerard de Visser Avatar answered Sep 22 '26 14:09

Gerard de Visser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!