致命错误:调用成员函数toOptionArray()

时间:2012-05-27 10:09:25

标签: php function magento e-commerce

当我到达System>>配置>>我的magento仪表板中的Google API出现以下错误。

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

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

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

由于

1 个答案:

答案 0 :(得分:1)

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

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'));
}

将以上代码替换为以下代码:

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);
}
}

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