The reason your module needs a helper class is the module
argument in the system.xml file:
<cashondelivery translate="label" module="cashondelivery">
Magento passes the module
argument to the Mage::helper()
factory method. This in turn completes the class id to cashondelivery/data
.
Mage::helper('cashondelivery');
// identical to Mage::helper('cashondelivery/data');
Now Magento checks for the class prefix to use by looking for the node global/helpers/cashondelivery/class
which is missing.
Rather straightforward so far, but here is where it might be a little confusing for some.
If Magento doesn't find a helper class prefix, it tries to makes one up by prefixing the class id with mage_
and appending _helper
.
So this gives you mage_cashondelivery_helper
as the class prefix, and mage_cashondelivery_helper_data
as the full class name.
The autoloader turns this into Mage/Cashondelivery/Helper/Data.php, which can't be found, and hence the exception you are experiencing.
Besides creating the Companyname_Cashondelivery_Helper_Data
class, you need to add the class group mapping to your config.xml file as follows:
<global>
<helpers>
<cashondelivery>
<class>Companyname_Cashondelivery_Helper</class>
</cashondelivery>
</helpers>
</global>
This class group to class prefix mapping is all you are missing.
Best Answer
In your system.xml you have the following code
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:
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.