1

我刚刚遵循了有关如何创建简单模型观察器的教程。当用户单击“继续结帐”时,这里有人可以帮助我或指出正确的方向来调用该方法吗?

这是代码:

 <events>
  <checkout_onepage_controller_success_action>
    <observers>
      <sales_order_place_before>
        <type>singleton</type>
        <class>my_Observer</class>
        <method>send_email</method>
      </sales_order_place_before>
    </observers>
  </checkout_onepage_controller_success_action>     
 </events> 
4

1 回答 1

2

尝试

创建:app/code/local/MagePal/MyCheckout/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <MagePal_MyCheckout>
            <version>1.0.1</version>
        </MagePal_MyCheckout>
    </modules>

    <global>
        <models>
            <magepal_mycheckout>
                <class>MagePal_MyCheckout_Model</class>
            </magepal_mycheckout>
        </models>
         <events>
            <checkout_onepage_controller_success_action>
                <observers>
                    <magepal_mycheckout>
                        <type>singleton</type>
                        <class>mycheckout/observer</class>
                        <method>sendEmail</method>
                    </magepal_mycheckout>
                </observers>
            </checkout_onepage_controller_success_action>
        </events>
    </global>
</config>

创建:app/code/local/MagePal/MyCheckout/Model/Observer.php

class MagePal_MyCheckout_Model_Observer 
{
    /**
     *
     * @param Varien_Event_Observer $observer
     * @return object
     */
    public function sendEmail(Varien_Event_Observer  $observer)
    {
        //add logic here

        return $this;
    }
}

创建:app/etc/modules/MagePal_MyCheckout.xml

  <?xml version="1.0"?>
    <config>
           <modules>
                  <MagePal_MyCheckout>
                          <active>true</active>
                          <codePool>local</codePool>
                  </MagePal_MyCheckout>
           </modules>
    </config>
于 2013-05-28T15:23:05.197 回答