Magento module Fatal error: Class 'Mage_Cashondelivery_Helper_Data' not found in \xampp\htdocs\magento\app\Mage.php on line 516

后端 未结 1 656
独厮守ぢ
独厮守ぢ 2020-12-10 06:39

I am developing a payment Module for Magento. I did this using this tutorial

http://www.magentocommerce.com/wiki/5_-_modules_and_development/payment/create-payment-m

相关标签:
1条回答
  • 2020-12-10 07:13

    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.

    0 讨论(0)
提交回复
热议问题