2012-02-08 21 views
7

पर \ xampp \ htdocs \ Magento \ app \ Mage.php में क्लास 'Mage_Cashondelivery_Helper_Data' नहीं मिला है, मैं Magento के लिए भुगतान मॉड्यूल विकसित कर रहा हूं। मैं इस ट्यूटोरियलMagento मॉड्यूल घातक त्रुटि: कक्षा 516

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

<?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> 

एप्लिकेशन/स्थानीय/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> 
,210

तो मैं एक मॉडल श्रेणी का निर्माण

<?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 
    */   
} 
?> 

मैं भी एप्लिकेशन/स्थानीय/CompanyName/Cashondelivery/हेल्पर/Data.php

<?php 
class Companyname_Cashondelivery_Helper_Data extends Mage_Core_Helper_Abstract 
{ 
} 
?> 

में एक फ़ाइल बनाया है लेकिन जब मैं खोलने मैं कोई त्रुटि मिलती है विन्यास> भुगतान की विधि

गंभीर त्रुटि: क्लास 'Mage_Cashondelivery_Helper_Data' सी में नहीं मिला: \ XAMPP \ htdocs \ Magento \ एप्लिकेशन \ Mage.php लाइन पर 516

यह है एक सहायक वर्ग के लिए आवश्यक है।

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

Magento के लिए module तर्क गुजरता है: मैं सहायकों और Data.php

उत्तर

18

कारण अपने मॉड्यूल की जरूरत है एक सहायक वर्ग System.Xml फ़ाइल में module तर्क है के बारे में पता नहीं है Mage::helper() फैक्टरी विधि। यह बदले में कक्षा आईडी को cashondelivery/data पर पूरा करता है।

Mage::helper('cashondelivery'); 
// identical to Mage::helper('cashondelivery/data'); 

अब Magento वर्ग उपसर्ग नोड global/helpers/cashondelivery/class जो याद आ रही है की तलाश द्वारा उपयोग करने के लिए के लिए जाँच करता है।

बल्कि अभी तक सीधा है, लेकिन यहां यह है कि यह कुछ के लिए थोड़ा उलझन में हो सकता है।
यदि Magento को एक सहायक वर्ग उपसर्ग नहीं मिला है, यह mage_ के साथ कक्षा आईडी को उपसर्ग करके _helper जोड़कर को बनाने का प्रयास करता है।
तो यह आपको कक्षा उपसर्ग के रूप में mage_cashondelivery_helper और पूर्ण श्रेणी नाम के रूप में mage_cashondelivery_helper_data देता है।

ऑटोलोडर इसे मैज/कैशोन्डेलिवरी/हेल्पर/डेटा.एफपी में बदल देता है, जो नहीं मिल सकता है, और इसलिए आप जो अपवाद अनुभव कर रहे हैं।

Companyname_Cashondelivery_Helper_Data कक्षा बनाने के अलावा, आपको अपनी कॉन्फ़िगरेशन में क्लास समूह मैपिंग जोड़ने की आवश्यकता है।xml फ़ाइल इस प्रकार है:

<global> 
    <helpers> 
    <cashondelivery> 
     <class>Companyname_Cashondelivery_Helper</class> 
    </cashondelivery> 
    </helpers> 
</global> 

वर्ग उपसर्ग मानचित्रण करने के लिए इस वर्ग के समूह सब आप याद कर रहे हैं है।

+0

धन्यवाद vinai। वह समस्या हल हो गई। मैंने config.xml में xml कोड जोड़ा है। लेकिन मैं सोच रहा हूं कि मैं एक ही उपरोक्त कोड के लिए यह त्रुटि क्यों हूं। घातक त्रुटि: लाइन 421 – naquiuddin

+0

पर डी: \ xampp \ htdocs \ magento \ app \ code \ core \ mage \ adminhtml \ block \ System \ Config \ Form.php में एक गैर-ऑब्जेक्ट पर किसी सदस्य फ़ंक्शन कोऑपरएरे() पर कॉल करें। इस http://stackoverflow.com/questions/9205289/fatal-error-call-to-a-member-function-tooptionarray-on-a-non-object – naquiuddin

+0

धन्यवाद के लिए एक प्रश्न जोड़ा है धन्यवाद, दोस्त। मैं इसके बारे में पागल हो रहा था। आपकी पोस्ट बहुत उपयोगी रही है। –

संबंधित मुद्दे