Magento - customer_save_after always fired twice

Magento - customer_save_after always fired twice

July 18, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - customer_save_after always fired twice

Understanding Magento’s Event Dispatcher: Why customer_save_after is Fired Twice

Magento’s event-driven architecture allows for powerful extensibility, but it can sometimes lead to unexpected behavior like the customer_save_after event firing twice. In this post, we’ll explore why this happens and provide a solution to handle it efficiently.

The Underlying Issue

In Magento, events are dispatched through the Zend_EventManager singleton instance. By default, when an event is triggered, all registered observers are notified in sequential order based on their priority. This means that if multiple modules register the same observer for the same event, they will be executed one after another.

In your case, even though you haven’t found any other module rewriting the customer_save_after event, it’s possible that Magento itself is dispatching this event twice due to internal logic. For instance, the event might be fired once by the core model and then again by a helper or controller action during customer save operations.

Inspecting the Event Flow

To verify if another module is indeed causing the second dispatch, you can enable Magento’s debug logging for events:

  1. Open your app/etc/local.xml file.
  2. Add the following lines inside the <config> tags to enable event debugging:
<event>
    <debug>true</debug>
</event>
  1. Save the file and restart Apache.

Now, when you save a customer, Magento will log all dispatched events along with their observers in var/log/system.log. Check this log for any hints about what might be triggering the second dispatch of customer_save_after.

A Practical Solution

Rather than trying to prevent the event from firing twice (which can be challenging due to Magento’s internal processes), a more reliable approach is to implement logic within your observer that handles multiple dispatches gracefully.

Here’s an example of how you could modify your observer:

class Company_Custommodule_Model_Observer
{
    public function customerSaveAfter($observer)
    {
        $customer = $observer->getEvent()->getCustomer();
        if ($customer->getId() > 0) { // Check if the event corresponds to an actual save operation
            // Your logic here. This block will only be executed once, even if event is fired twice.
        }
    }
}

By checking if the customer ID exists and is greater than zero (indicating a real customer was saved), we ensure that our logic only executes when the event corresponds to an actual save operation.

Conclusion

While Magento’s customer_save_after event firing twice might seem counterintuitive, it’s a common occurrence due to the way events are dispatched in the core. By implementing smart observer logic and using proper debugging techniques, you can handle these situations effectively without disrupting Magento’s internal processes.

Remember that the key is not to prevent the second dispatch, but to write observers that are robust enough to handle multiple dispatches gracefully. This approach ensures your code remains stable even if Magento’s event handling changes in future updates.

For more insights on Magento development best practices and efficient event management, check out our Magento Development Guide at LaravelCompany.com.

Security API Extensions Configuration

Our network