0

有一个自定义观察者没有接受事件的问题。该模块已启用并显示在仪表板的高级部分中。我已经清除了所有缓存等,所以它必须是一个小配置问题。

任何人都可以帮助发现问题吗?

配置文件

<modules>
    <Hatclub_MembershipHandler>
        <version>1.0.0</version>
    </Hatclub_MembershipHandler>
</modules>

<global>

    <models>
        <dispatcher>
            <class>Hatclub_MembershipHandler_Model</class>
        </dispatcher>
    </models>

    <events>

        <customer_register_success>
            <observers>
                <registration_success_observer>
                    <class>dispatcher/observer</class>
                    <method>associateMembership</method>
                </registration_success_observer>
            </observers>
        </customer_register_success>

        <customer_session_init>
            <observers>
                <session_init_observer>
                    <class>dispatcher/observer</class>
                    <method>associateMembership</method>
                </session_init_observer>
            </observers>
        </customer_session_init>

        <customer_login>
            <observers>
                <login_observer>
                    <class>dispatcher/observer</class>
                    <method>associateMembership</method>
                </login_observer>
            </observers>
        </customer_login>

    </events>

</global>

观察者.php

class Hatclub_MembershipHandler_Model_Observer {

    // this is hook to magento event dispatched before action is run [only allow if membership exists]
    public function associateMembership(Varien_Event_Observer $observer) {

        // event
        $event = $observer->getEvent()->getControllerAction()->getFullActionName();

        Mage::log('**** EVENT FIRED ****' . $event);

        Mage::log(json_encode($observer->getEvent()));

    }

}
4

1 回答 1

2

修改你config.xml

<modules>
    <Hatclub_MembershipHandler>
        <version>1.0.0</version>
    </Hatclub_MembershipHandler>
</modules>

<global>

    <models>
        <dispatcher>
            <class>Hatclub_MembershipHandler_Model</class>
        </dispatcher>
    </models>

    <events>

        <customer_register_success>
            <observers>
                <registration_success_observer>
                    <class>Hatclub_MembershipHandler_Model_Observer</class>
                    <method>associateMembership</method>
                </registration_success_observer>
            </observers>
        </customer_register_success>

        <customer_session_init>
            <observers>
                <session_init_observer>
                    <class>Hatclub_MembershipHandler_Model_Observer</class>
                    <method>associateMembership</method>
                </session_init_observer>
            </observers>
        </customer_session_init>

        <customer_login>
            <observers>
                <login_observer>
                    <class>Hatclub_MembershipHandler_Model_Observer</class>
                    <method>associateMembership</method>
                </login_observer>
            </observers>
        </customer_login>

    </events>

</global>

您提到了错误的班级名称。

于 2013-01-13T08:58:02.590 回答