Magento:致命错误:在第 432 行的 appMage.php 中的非对象上调用成员函数 getModelInstance() [英] Magento: Fatal error: Call to a member function getModelInstance() on a non-object in appMage.php on line 432

查看:20
本文介绍了Magento:致命错误:在第 432 行的 appMage.php 中的非对象上调用成员函数 getModelInstance()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 ajax 调用 PHP 文件,在该 PHP 中我将通过 ajax 调用下订单.但是当我使用该文件中的 app/Mage.php 时它会抛出错误

I want to call a PHP file using ajax where in that PHP i will place order by the ajax call. But it throws error while i am using app/Mage.php from that file

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

然后它说

致命错误:调用成员函数 getModelInstance()第 432 行的 appMage.php 中的非对象

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

谁能帮帮我???

推荐答案

您提出的解决方案不是最佳的.您尚未初始化 Magento,因此模块 XML 尚未加载且工厂模式不起作用.

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.

只需使用:

Mage::init(); // 1.5+ 

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

在使用 getModel 之前.

before using getModel.

这篇关于Magento:致命错误:在第 432 行的 appMage.php 中的非对象上调用成员函数 getModelInstance()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆