Magento Observer没有开火,为什么?

时间:2014-04-07 20:25:49

标签: magento model observers

我与观察者有困难,不知道如何解决它!

这是我的config.xml和Observer.php文件

MyCompany的/ Mymodule中的/ etc / config.xml中

<?xml version="1.0"?>    
<global>
        <models>
            <mymodule>
                <class>Mycompany_Mymodule_Model</class>
                <resourceModel>mymodule_mysql4</resourceModel>
            </mymodule>
            <mymodule_mysql4>
                <class>Mycompany_Mymodule_Model_Mysql4</class>
                <entities>
                    <mymodule>
                        <table>mymodule</table>
                    </mymodule>
                </entities>
            </mymodule_mysql4>
        </models>
        <events>
            <checkout_type_onepage_save_order_after>
                <observers>
                    <mycompany_mymodule_order_complete>
                        <class>mymodule/observer</class>
                        <method>mymoduleCompleteOrder</method>
                    </mycompany_mymodule_order_complete>
                </observers>
            </checkout_type_onepage_save_order_after>
       </events>
 </global>

MyCompany的/ Mymodule中/型号/ Observer.php

class Mycompany_Mymodule_Model_Observer 
{
    protected $_config;

    protected function _construct()
    {
        $this->_config = Mage::getModel('mymodule/config');
    }

    public function mymoduleCompleteOrder($observer)
    {...
      ....
    } 

1 个答案:

答案 0 :(得分:0)

尝试改变:

<events>
            <checkout_type_onepage_save_order_after>
                <observers>
                    <mycompany_mymodule_order_complete>
                        <type>singleton</type>
                        <class>mymodule/observer</class>
                        <method>mymoduleCompleteOrder</method>
                    </mycompany_mymodule_order_complete>
                </observers>
            </checkout_type_onepage_save_order_after>
       </events>