The implementation of the Mage_Checkout_Model_Cart::save() method seems to result in duplication of events. Why is the non-standard checkout_cart_save_after event thrown immediately after the generic sales_quote_save_after event would have been thrown by the successful save.

Are there are reasons to listen for one of the events instead of the other? I can see that the sales_quote_save_after event would be thrown by admin or API orders, but they can be excluded from observers via specifying the eventname inside the <frontend> XML node in the module's config.xml anyway.

To provide a more concrete reason for the question, we have inherited code that listens to the checkout_cart_save_after event and I am concerned that it might be missing scenarios when the quote is changed but that event is not thrown.

Reference code from /app/code/core/Mage/Checkout/Model/Cart.php:473:

    Mage::dispatchEvent('checkout_cart_save_before', array('cart'=>$this));

     * Cart save usually called after changes with cart items.
    Mage::dispatchEvent('checkout_cart_save_after', array('cart'=>$this));

2 Answers 2


If this were a standard ORM model these events would likely exist. Because the Mage_Checkout_Model_Cart model extends Varien_Object instead of Mage_Core_Model_Abstract, these events are dispatched by hand, including the passing of the cart object into the event scope. This allows for similar event-based injection of processing logic related to the cart object before and after the quote save process.


You can save quote from wherever in your code and it is done a lot in core , $cart is saved through cart controller (mostly) and I guess it's a sort of wrapper around quote (As quote is cart in Magento) object trying to separate general quote save and events that happen directly related to actions through cartController

What drived me to this conclusion was the following grep

grep 'cart\->' app/ -rsn

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.