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?
Add to config.xml
<global>
<models>
<stockindicator>
<class>Namespace_ModuleName_Model</class>
</stockindicator>
</models>
</global>
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.
This should solve the error:-
- Disable Compilation (
System -> Tools -> Compilation
)
- Refresh Cache (
System -> Cache Management
)
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.
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
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);
}