3 added 22 characters in body
source | link

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:

  1. Plugins can modify only public methods while observers can modify private, protected as well.
  2. There is sort order for plugins but there is no sort order for observers.
  3. You can add observer only to the events that are already dispatched in Magento. Plugins are more flexible here.

Plugins are used to transform data that is passed to or from public methods while the data that is sent to events should not be transformed. Observers do some business logic, they do not modify data. For example, you can send a notification email in your observer when an action has occurred.

Main difference between plugins and observers is:

  1. Plugins can modify only public methods while observers can modify private, protected as well.
  2. There is sort order for plugins but there is no sort order for observers.
  3. You can add observer only to the events that are already dispatched in Magento. Plugins are more flexible here.

According to Magento technical guide (https://devdocs.magento.com/guides/v2.1/coding-standards/technical-guidelines.html#14-events): All values (including objects) passed to an event MUST NOT be modified in the event observer. Instead, plugins SHOULD BE used for modifying the input or output of a function.

For me the main difference between plugins and observers is:

  1. Plugins can modify only public methods while observers can modify private, protected as well.
  2. There is sort order for plugins but there is no sort order for observers.
  3. You can add observer only to the events that are already dispatched in Magento. Plugins are more flexible here.
2 added 344 characters in body
source | link

Plugins are used to transform data that is passed to or from public methods while the data that is sent to events should not be transformed. Observers do some business logic, they do not modify data. For example, you can send a notification email in your observer when an action has occurred.

Main difference between plugins and observers is:

  1. Plugins can modify only public methods while observers can modify private, protected as well.
  2. There is sort order for plugins but there is no sort order for observers.
  3. You can add observer only to the events that are already dispatched in Magento. Plugins are more flexible here.

Plugins are used to transform data that is passed to or from public methods while the data that is sent to events should not be transformed. Observers do some business logic, they do not modify data. For example, you can send a notification email in your observer when an action has occurred.

Plugins are used to transform data that is passed to or from public methods while the data that is sent to events should not be transformed. Observers do some business logic, they do not modify data. For example, you can send a notification email in your observer when an action has occurred.

Main difference between plugins and observers is:

  1. Plugins can modify only public methods while observers can modify private, protected as well.
  2. There is sort order for plugins but there is no sort order for observers.
  3. You can add observer only to the events that are already dispatched in Magento. Plugins are more flexible here.
1
source | link

Plugins are used to transform data that is passed to or from public methods while the data that is sent to events should not be transformed. Observers do some business logic, they do not modify data. For example, you can send a notification email in your observer when an action has occurred.