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



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

Avatar

Adarsh

November 27th, 2014 at 8:01 am

Great article thanks

Comment Form

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Categories

Latest comments


    Fatal error: Uncaught Error: Call to undefined function split() in /home4/nos/public_html/naveenos.com/wp-content/themes/smoker/functions.php:72 Stack trace: #0 /home4/nos/public_html/naveenos.com/wp-content/themes/smoker/sidebar.php(11): mdv_recent_comments() #1 /home4/nos/public_html/naveenos.com/wp-content/themes/smoker/single.php(47): include('/home4/nos/publ...') #2 /home4/nos/public_html/naveenos.com/wp-includes/template-loader.php(74): include('/home4/nos/publ...') #3 /home4/nos/public_html/naveenos.com/wp-blog-header.php(19): require_once('/home4/nos/publ...') #4 /home4/nos/public_html/naveenos.com/index.php(17): require('/home4/nos/publ...') #5 {main} thrown in /home4/nos/public_html/naveenos.com/wp-content/themes/smoker/functions.php on line 72