Plugins are usedAccording to transform data that isMagento technical guide (https://devdocs.magento.com/guides/v2.1/coding-standards/technical-guidelines.html#14-events): All values (including objects) passed to or from public methods while the data that is sent to events should notan event MUST NOT be transformed. Observers do some business logic, they do not modify datamodified in the event observer. For exampleInstead, you can sendplugins SHOULD BE used for modifying the input or output of a notification email in your observer when an action has occurredfunction.
MainFor me the main difference between plugins and observers is:
- Plugins can modify only public methods while observers can modify private, protected as well.
- There is sort order for plugins but there is no sort order for observers.
- You can add observer only to the events that are already dispatched in Magento. Plugins are more flexible here.