Magento: Fatal error: Call to a member function getModelInstance() on a non-object in appMage.php on line

April 13, 2012 | In: Fatel Error, Linux, Magento, web development

Today we are working on cron file that will call all model methods of my custom module. But we are getting error:

"Magento: Fatal error: Call to a member function getModelInstance() on a non-object in appMage.php on line 141".

when we are using:

require_once 'app/Mage.php';    
$customobj = Mage::getModel('custommodule/custommodule');

It was amazing for us that we developed many extension but never get such type of issue.
What may be reason? Oooofff……..hmmm….

Then we just copy other cron file code to this cron file and its work. :)

We have found our solution and exact reason. We didn’t initialize magento app.

It was so simple:

Mage::init(); // 1.5+

OR

Mage::app(); // below 1.5

You may also like these related posts

  • Adarsh

    Great article thanks

Categories

By Google