2012-05-27 31 views
1

当我从我的magento仪表板访问System >> COnfiguration >> Google API时,出现以下错误。致命错误:调用成员函数toOptionArray()

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

确保'$ sourceModel'是一个对象,例如你做了这样的事情:'$ sourceModel = new Class;' – Leri

+0

@PLB非常感谢。我通过安装所有模块并更新它们来解决它。 – FlourishDNA

+0

@Pekka我知道我应该发布在Magento支持论坛上,但很难在那里得到答复。我喜欢Stack Exchange,因为我们在这里得到及时答复。谢谢 – FlourishDNA

回答

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/

+1

非常感谢小费。我浏览了Magento日志。该错误是由Fooman GoogleAnalyticsPlus模块引起的。升级它解决了这个问题。 – FlourishDNA

相关问题