Having some trouble here. What I'm hoping to accomplish is the following:

Prior to making a change to a customer's account group through the admin panel, I'd like to get their account group ID. This value will serve as the previousAccountGroupID.

After save, I'd like to again pull the account group ID to serve as the postAccountGroupID.

I'd like to be able to compare these values to see if the account group has changed, as well as specific cases related to changing from a certain account group to another certain account group. However, we'll ignore that for now as it's irrelevant within the scope of this question.

My issue is this: I'm having trouble getting the account group ID prior to that save. I've written an observer which looks for various events, but it seems that no matter what event I try to observe, it always gives me the NEW account group ID. I can't seem to get the previous account group ID.

Here are the events I've tried observing:

adminhtml_customer_prepare_save customer_save_after customer_address_save_after

When observing any of these events, the customer group ID is already set (at least within the model) to what it is being updated to. Here's a code sample of one of those events (the one that seems most logical to me) as well as the output:

Excerpt from: testmodule/etc/config.xml


Excerpt from: testmodule/Model/Adminhtml/Observer.php

public function saveCustomerAttributes($observer = null)

    $_customer = $observer->getCustomer();
    Mage::log('in here! ' . $_customer->getGroupId(), null, 'test.log');


What is written to my log is always the ID of the group which I am changing the account to. It is never what it was previously set to before the modification. My presumption is simply that this is not the correct event to observe. However, like I said I have tried a number of different events and none have given me the results I want.

Hopefully that's enough to go on. Please let me know if I can clarify anything. Until then, I'll be here scratching my head :/

  • 1
    Did you try $_customer->getOrigData(); Commented Nov 4, 2014 at 21:19
  • @R.S. Post this as an asnswer. Of course...make it a little more significant.
    – Marius
    Commented Nov 4, 2014 at 21:25
  • @R.S That did it! Will mark as answered when you move your comment to an answer. Thanks :)
    – carbide20
    Commented Nov 4, 2014 at 21:31

1 Answer 1


Take a look at What is the difference between $model->getOrigData(); and $model->getData();?





This will returns the data in the object at the time it was initialised/load.

Also take a look at Class Varien_Object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.