Fatal error: Call to a member function toOptionArr

2019-02-26 13:43发布

When i click on Shipping Methods tab under Magento system->configuration->SALES tab I am faced with the following error:

Fatal error: Call to a member function toOptionArray() on a non-object in D:\xampp\htdocs\magento\app\code\core\Mage\Adminhtml\Block\System\Config\Form.php on line 463

The most astounding thing is that this is a fresh installation of Magento. Can anyone tell me how can i remove this error?

6条回答
做自己的国王
2楼-- · 2019-02-26 13:58

According to webshopapps support all you should need to do is compile through system->tools->compilation. Personally I compiled, flushed caches, logged out and logged in again. It worked.

I had previously tried the update modules method and had to restore from a backup after it broke magento 1.9.0.1

查看更多
ら.Afraid
3楼-- · 2019-02-26 14:03

Add to config.xml

<global>
    <models>
        <stockindicator>
            <class>Namespace_ModuleName_Model</class>
        </stockindicator>
    </models>
</global>
查看更多
一夜七次
4楼-- · 2019-02-26 14:04

I ran into this issue and none of the existing answers out there helped. After some trial and error, I discovered my issue was due to a case sensitive issue between running on Windows and Linux.

My widget.xml file contained this line:

<source_model>widget/modeoptions</source_model>

My model class was declared as:

class My_Widget_Model_ModeOptions

This worked as expected when deployed out an an Magento instance running in Mirosoft Azure. When I deployed the same exact code to a Magento instance running on Linux, I received the error.

Call to a member function toOptionArray() on a non-object in ../includes/src/Mage_Widget_Block_Adminhtml_Widget_Options.php

After updating the widget.xml to match the class' case, everything worked as expected on a Windows and Linux server.

Updated/fixed line:

<source_model>widget/ModeOptions</source_model>

Hope this might help some others struggling with this error.

查看更多
对你真心纯属浪费
5楼-- · 2019-02-26 14:04

Go to app\code\core\Mage\Adminhtml\Block\System\Config\Form.php

find the following on line 463

$optionArray = $sourceModel->toOptionArray($fieldType == ‘multiselect’);

and replace it with:

if(is_object($sourceModel)){
$optionArray = $sourceModel->toOptionArray($fieldType == ‘multiselect’);
} else {
Mage::log($e->source_model);
}
查看更多
6楼-- · 2019-02-26 14:05

This should solve the error:-

  1. Disable Compilation (System -> Tools -> Compilation)
  2. Refresh Cache (System -> Cache Management)
查看更多
爱情/是我丢掉的垃圾
7楼-- · 2019-02-26 14:14

Following this tutorial solve the problem => http://kb.magenting.com/content/20/49/en/magento-error-call-to-a-member-function-tooptionarray-on-a-non-object.html

Go to Magento Connect Manager, click Check For Upgrades. In Actions, upgrade the modules that have the new version, and reinstall these modules:

  • Interface_Adminhtml_Default
  • Mage_All_Latest
  • Mage_Core_Adminhtml
  • Mage_Core_Modules

Check mark the "Clear all sessions after successfull install or upgrade", and then click Commit Changes.

查看更多
登录 后发表回答