Chapter 6. Plugins

In this chapter, we will take a look at a feature of Magento called plugins. Before we start with plugins, we first need to understand the term interception because the two terms are used somewhat interchangeably when dealing with Magento.

Interception is a software design pattern that is used when we want to insert code dynamically without necessarily changing the original class behavior. This works by dynamically inserting code between the calling code and the target object.

The interception pattern in Magento is implemented via plugins. They provide the before, after, and around listeners, which help us extend the observed method behavior.

In this chapter, we will cover the following topics:

  • Creating a plugin
  • Using the before ...

Get Magento 2 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.