app/code/core/Customer/etc/config.xml
在 Magento 保存地址之前和之后注册观察者:
<events>
<customer_address_save_before>
<observers>
<customer_address_before_save_viv_observer>
<class>customer/observer</class>
<method>beforeAddressSave</method>
</customer_address_before_save_viv_observer>
</observers>
</customer_address_save_before>
<customer_address_save_after>
<observers>
<customer_addres_after_save_viv_observer>
<class>customer/observer</class>
<method>afterAddressSave</method>
</customer_addres_after_save_viv_observer>
</observers>
</customer_address_save_after>
</events>
…但我找不到任何证据表明 Magento 实际上在任何地方发送这些事件:
$ grep -RF 'dispatchEvent(' . | grep -F customer_addres
./app/code/core/Mage/Customer/Model/Address/Abstract.php: Mage::dispatchEvent('customer_address_format', array('type' => $formatType, 'address' => $this));
据我了解Mage::dispatchEvent(…)
,这是 Magento 触发事件的唯一方法。这些事件真的发生了吗?(我希望如此,因为我真的可以使用一些在地址保存时间触发的事件。)