Magento模块致命错误:在第516行的\ xampp \ htdocs \ magento \ app \ Mage.php中找不到类'Mage_Cashondelivery_Helper_Data' [英] Magento module Fatal error: Class 'Mage_Cashondelivery_Helper_Data' not found in \xampp\htdocs\magento\app\Mage.php on line 516

查看:80
本文介绍了Magento模块致命错误:在第516行的\ xampp \ htdocs \ magento \ app \ Mage.php中找不到类'Mage_Cashondelivery_Helper_Data'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Magento开发付款模块.我是使用本教程完成的

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-method-module

我已创建文件夹

app/local/Companyname/Cashondelivery/Block
app/local/Companyname/Cashondelivery/Model
app/local/Companyname/Cashondelivery/controller
app/local/Companyname/Cashondelivery/etc
app/local/Companyname/Cashondelivery/helpers

etc/config.xml

The etc/config.xml

    <?xml version="1.0"?>
    <config>
        <modules>
           <Companyname_Cashondelivery>
    <!-- declare module's version information for database updates -->
              <version>0.1.0</version>
           </Companyname_Cashondelivery>
        </modules>

        <global>


    <!-- declare model group for new module -->
            <models>
    <!-- model group alias to be used in Mage::getModel('newmodule/...') -->
                <createorder>
    <!-- base class name for the model group -->
                    <class>Companyname_Cashondelivery_createorder</class>
                </createorder>
            </models>

    <!-- declare resource setup for new module -->
            <resources>
    <!-- resource identifier -->
                <cashondelivery_setup>
    <!-- specify that this resource is a setup resource and used for upgrades -->
                    <setup>
    <!-- which module to look for install/upgrade files in -->
                        <module>Companyname_Cashondelivery</module>
                    </setup>
    <!-- specify database connection for this resource -->
                    <connection>
    <!-- do not create new connection, use predefined core setup connection -->
                        <use>core_setup</use>
                    </connection>
                </cashondelivery_setup>
                <cashondelivery_write>
                    <connection>
                      <use>core_write</use>
                    </connection>
                </cashondelivery_write>
                <cashondelivery_read>
                   <connection>
                    <use>core_read</use>
                  </connection>
                </cashondelivery_read>
            </resources>
        </global>

    <!-- declare default configuration values for this module -->
        <default>
    <!-- 'payment' configuration section (tab) -->
            <payment>
    <!-- 'newmodule' configuration group (fieldset) -->
                <cashondelivery>
    <!-- by default this payment method is inactive -->
                    <active>0</active>
    <!-- model to handle logic for this payment method -->
                    <model>cashondelivery/createorder</model>
    <!-- order status for new orders paid by this payment method -->
                    <order_status>pending</order_status>
    <!-- default title for payment checkout page and order view page -->
                    <title>Companyname</title>                
                </cashondelivery>
             </payment>
        </default>
</config>

app/local/Companyname/Modulename/etc/system.xml

The app/local/Companyname/Modulename/etc/system.xml

<?xml version="1.0"?>
<config>
   <sections>
        <payment>
            <groups>
                <cashondelivery translate="label" module="cashondelivery">
                    <label>Cash On Delivery</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>10</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <!--<comment>[CDATA[<a href="http://celinks.magento.com/authorize_netRegistration" target="_blank">Click here to sign up for an Authorize.net account</a>]]></comment>-->
                    <fields>
                        <active translate="label">
                            <label>Enabled</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </active>
                        <email_customer translate="label">
                            <label>Email Customer</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </email_customer>
                        <login translate="label">
                            <label>API Login ID</label>
                            <frontend_type>obscure</frontend_type>
                            <backend_model>adminhtml/system_config_backend_encrypted</backend_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>
                        </login>

                        <merchant_email translate="label">
                            <label>Merchant's Email</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>11</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </merchant_email>
                        <order_status translate="label">
                            <label>New Order Status</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_order_status_processing</source_model>
                            <sort_order>4</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </order_status>
                        <sort_order translate="label">
                            <label>Sort Order</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>100</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </sort_order>
                        <test translate="label">
                            <label>Test Mode</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </test>
                        <debug translate="label">
                            <label>Debug</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>6</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </debug>
                        <title translate="label">
                            <label>Title</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </title>

                        <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>
                        <cgi_url>
                            <label>Gateway URL</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </cgi_url>                        
                        <min_order_total translate="label">
                            <label>Minimum Order Total</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>98</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </min_order_total>
                        <max_order_total translate="label">
                            <label>Maximum Order Total</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>99</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </max_order_total>
                        <allow_partial_authorization translate="label">
                            <label>Allow Partial Authorization</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>110</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </allow_partial_authorization>                     
                        <model>
                        </model>
                    </fields>
                </cashondelivery>
            </groups>
        </payment>
    </sections>
</config>

然后我创建了一个模型类

Then I created a model class

<?php 
/**
* Our test CC module adapter
*/
class Companyname_Cashondelivery_Model_createorder extends Mage_Payment_Model_Method_Cc
{
    /**
    * unique internal payment method identifier
    *
    * @var string [a-z0-9_]
    */
    protected $_code = 'newmodule';

    /**
     * Here are examples of flags that will determine functionality availability
     * of this module to be used by frontend and backend.
     *
     * @see all flags and their defaults in Mage_Payment_Model_Method_Abstract
     *
     * It is possible to have a custom dynamic logic by overloading
     * public function can* for each flag respectively
     */

    /**
     * Is this payment method a gateway (online auth/charge) ?
     */
    protected $_isGateway               = true;

    /**
     * Can authorize online?
     */
    protected $_canAuthorize            = true;

    /**
     * Can capture funds online?
     */
    protected $_canCapture              = false;

    /**
     * Can capture partial amounts online?
     */
    protected $_canCapturePartial       = false;

    /**
     * Can refund online?
     */
    protected $_canRefund               = false;

    /**
     * Can void transactions online?
     */
    protected $_canVoid                 = true;

    /**
     * Can use this payment method in administration panel?
     */
    protected $_canUseInternal          = true;

    /**
     * Can show this payment method as an option on checkout payment page?
     */
    protected $_canUseCheckout          = true;

    /**
     * Is this payment method suitable for multi-shipping checkout?
     */
    protected $_canUseForMultishipping  = true;

    /**
     * Can save credit card information for future processing?
     */
    protected $_canSaveCc = false;

    /**
     * Here you will need to implement authorize, capture and void public methods
     *
     * @see examples of transaction specific public methods such as
     * authorize, capture and void in Mage_Paygate_Model_Authorizenet
     */        
}
?>

我什至在app/local/Companyname/Cashondelivery/Helper/Data.php中创建了一个文件

I have even created a file in app/local/Companyname/Cashondelivery/Helper/Data.php

<?php
class Companyname_Cashondelivery_Helper_Data extends Mage_Core_Helper_Abstract
{
}
?>

但是当我打开配置">付款方式"

But I get an error when I open Configuration>Payment Methods

致命错误:在第516行的C:\ xampp \ htdocs \ magento \ app \ Mage.php中找不到类'Mage_Cashondelivery_Helper_Data'

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

是否需要一个Helper类.我不知道有关帮助器和Data.php的信息

Is it necessary to have a Helper class. I have no idea about the helpers and Data.php

推荐答案

您的模块需要帮助程序类的原因是 system.xml 文件中的module自变量:

The reason your module needs a helper class is the module argument in the system.xml file:

<cashondelivery translate="label" module="cashondelivery">

Magento将module参数传递给Mage::helper()工厂方法.依次将类ID补全为cashondelivery/data.

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');

现在,Magento通过查找缺少的节点global/helpers/cashondelivery/class来检查要使用的类前缀.

Now Magento checks for the class prefix to use by looking for the node global/helpers/cashondelivery/class which is missing.

到目前为止,它还很简单,但是在这里可能有些让人困惑.
如果Magento找不到助手类的前缀,它会尝试通过在类ID的前面加上mage_并附加_helper来弥补.
因此,这将为您提供mage_cashondelivery_helper作为类前缀,并为mage_cashondelivery_helper_data作为完整的类名.

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.

自动加载器将其转换为 Mage/Cashondelivery/Helper/Data.php ,找不到该文件,因此您遇到的异常.

The autoloader turns this into Mage/Cashondelivery/Helper/Data.php, which can't be found, and hence the exception you are experiencing.

除了创建Companyname_Cashondelivery_Helper_Data类外,还需要将类组映射添​​加到config.xml文件中,如下所示:

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.

这篇关于Magento模块致命错误:在第516行的\ xampp \ htdocs \ magento \ app \ Mage.php中找不到类'Mage_Cashondelivery_Helper_Data'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆