1

当我从我的 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');
                    }

谢谢

4

1 回答 1

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/

于 2012-05-27T10:36:36.387 回答