I’ve been trying to do something that seems like it should be simple:
- hook a MODEL_save_after event (or MODEL_save_before if that’s more appropriate)
- check getData() vs getOrigData() to see what changes the user has made
Now, in the example of the ‘customer_address’ model, edited through the backend, I find that both the save events are triggered twice.
The first time 'customer_address_save_before' is triggered, followed by 'customer_address_save_after'. In both cases getOrigData() and getData() are identical, except getData() has a new ‘updated_at’ value, and has a ‘store_id’ set (is this a bug?). So, the model doesn’t have the submitted data from the user yet. The events are both before entering user data or validation, so this is of no use.
'customer_address_save_before' is triggered, followed by 'customer_address_save_after' a second time. This time (in both cases), getOrigData() is empty, and getData() now has all the submitted data from the user. So I can’t compare on these events either! It appears this is after validation, saving, the lot!
I’m also unsure why the save process appears to occur twice?
Magento v1.3.2.4 in use.
Am I missing something?