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

雨燕双飞 提交于 2019-11-29 13:50:43

Your proposed solution is not optimal. You have not initialized Magento so module XML is not loaded yet and the factory pattern does not work.

Simply use either:

Mage::init(); // 1.5+ 

or

Mage::app(); // (pretty much anything) below 1.5

before using getModel.

You should initialize the Magento Framework first:

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::init($mageRunCode, $mageRunType, array());

you need to initialize magento. the safest way to initialize it is by using initializer before your actual call to the model

Mage::init();

$customer = Mage::getModel('customer/customer');

I got the same error message. The solution was different. I forgot to give the permission on the magento folder to the Apache.

chown -R apache:apache magento

I personally had solved it by using

$customer = new Mage_Customer_Model_Customer();

instead of using

$customer = Mage::getModel('customer/customer');

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!