Quote/QuoteItem addErrorInfo is not persistent

On Magento 1, I’m having an issue where the quote and quote item error messages is not persistent.

$item->addErrorInfo('cataloginventory', Mage_CatalogInventory_Helper_Data::ERROR_QTY, $message);

The above code is fine for set the status in that request. However, as soon as another request hit, the error message is not there any more e.g. $quote->getErrors() returns empty array.

I’ve tried to do $quote->save() as well as $quoteItem->save() but I don’t think that’s the reason.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Put a break point in
Mage_Sales_Model_Quote_Item::removeErrorInfosByParams
and Mage_Sales_Model_Quote_Item::_clearErrorInfo
to check if there’s any other observer method that reset the error info.

Solution 2

Confirming addErrorInfo is only for a single request and not persist into session.

The way Magento core handle the cart error is upon cart update and re-check before checkout progress.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply