I am developing a payment method module in Magento. When I click payment methods menu in Configuration of Magento I get the below error
Fatal error: Call to a member function toOptionArray() on a non-object in
\xampp\htdocs\magento\app\code\core\Mage\Adminhtml\Block\System\Config\Form.php
on line 421
Please see the below link for the code of module which I was developing
Magento module Fatal error: Class 'Mage_Cashondelivery_Helper_Data' not found in \xampp\htdocs\magento\app\Mage.php on line 516
I am using Xampp 1.7.3 and magento 1.6.1.
Please help.
In your system.xml you have the following code
<payment_action translate="label">
<label>Payment Action</label>
<frontend_type>select</frontend_type>
<source_model>cashondelivery/createorder</source_model>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</payment_action>
The source model is specified as cashondelivery/createorder
.
According to the code you posted in the question you reference, this class is a payment method model, not a source model.
If you implement the toOptionArray()
method on the model it would work as a system config source model as well, but that doesn't seem like a bad choice.
I would guess the source model you are looking for is something like paygate/authorizenet_source_paymentAction
.
Background
Source models in Magento exist to provide option lists to select and multiselects. For this purpose they implement the toOptionArray()
method.
The options are returned as an array that has the following format:
public function toOptionArray()
{
return array(
array('value' => $value1, 'label' => 'The label for option 1'),
array('value' => $value2, 'label' => 'The label for option 2'),
array('value' => $value3, 'label' => 'The label for option 3')
// ... etc ...
);
}
System configuration source models don't need to extend super class and don't need to implement any methods besides toOptionArray()
.
EAV select and multiselect attributes also make use of source models, but those need to extend eav/entity_attribute_source_abstract
and are more complex, so I'll won't go into more details at this place.