Fatal error: Call to a member function toOptionArray()

谁都会走 提交于 2019-12-11 09:52:59

问题


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


回答1:


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/



来源:https://stackoverflow.com/questions/10773148/fatal-error-call-to-a-member-function-tooptionarray

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