The Introduction

Magento 2, known for its involved architecture, handles user notifications through its message system. Despite being a seemingly simple feature, the process behind rendering messages involves multiple steps and is quite abstracted, making it a classic example of doing things the Magento way.

There are essentially two methods for displaying messages to users:

  • Cookie-based: These messages require a page reload to display the intended content (commonly used for user login messages, etc.)
  • AJAX-based: These allow for dynamic updates to the page content, eliminating the need for a full reload (typically used for checkout or catalog-related messages, etc.)

Since there is, unsurprisingly, no comprehensive documentation on this topic, I hope my findings will help you navigate Magento’s messaging system more effectively. For this exploration, I’ve used the “Add to Cart” event as an example to demonstrate how messages are triggered and displayed.

The flow chart

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like