致命错误:调用成员函数toOptionArray() [英] Fatal error: Call to a member function toOptionArray()

查看:100
本文介绍了致命错误:调用成员函数toOptionArray()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从我的magento仪表板进入System >> COnfiguration >> Google API时,出现以下错误消息。

 致命错误:在421行上的/home/dev/public_html/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php中的非对象上调用成员函数toOptionArray()

在第421行的Form.php中有以下代码。

} else {
$ optionArray = $ sourceModel-> toOptionArray($ fieldType =='multiselect');

谢谢

解决方案

解决上述错误。请打开上面的路径文件。

  if($ e-> source_model){
$ sourceModel = Mage: :getSingleton((字符串)$ E-> source_model);
if($ sourceModel instanceof Varien_Object){
$ sourceModel-> setPath($ path);
}
$ field-> setValues($ sourceModel-> toOptionArray($ fieldType =='multiselect'));
}

以上代码替换如下:

  if($ e-> source_model){
$ sourceModel = Mage :: getSingleton((string)$ e-> source_model);
if($ sourceModel instanceof Varien_Object){
$ sourceModel-> setPath($ path);

if(is_object($ sourceModel)){
$ field-> setValues($ sourceModel-> toOptionArray($ fieldType =='multiselect'));
} else {
Mage :: log($ e-> source_model);


来源:

When I got to System >> COnfiguration >> Google API from my magento dashboard I get following error.

Fatal error: Call to a member function toOptionArray() on a non-object in /home/dev/public_html/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 421

In Form.php on line 421 there is following code.

} else {
                        $optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
                    }

Thanks

To solve the above error. Please open the above path file.

if ($e->source_model) {
$sourceModel = Mage::getSingleton((string)$e->source_model);
if ($sourceModel instanceof Varien_Object) {
$sourceModel->setPath($path);
}
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
}

Replace above code with below:

if ($e->source_model) {
$sourceModel = Mage::getSingleton((string)$e->source_model);
if ($sourceModel instanceof Varien_Object) {
$sourceModel->setPath($path);
}
if(is_object($sourceModel)){
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
} else {
Mage::log($e->source_model);
}
}

Source: http://indianicorange.wordpress.com/2010/10/04/fatal-error-call-to-a-member-function-tooptionarray-on-a-non-object/

这篇关于致命错误:调用成员函数toOptionArray()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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