magento-plugins-interceptors
Installation
SKILL.md
Magento 2 Plugins (Interceptors)
Before writing code
Fetch live docs: Fetch https://developer.adobe.com/commerce/php/development/components/plugins/ for the official plugins guide with exact method signatures and limitations.
Conceptual Architecture
What Plugins Do
Plugins intercept public method calls on any non-final class, allowing you to modify arguments, return values, or wrap entire method execution — without modifying the original class or using inheritance.
Three Plugin Types
| Type | Method Prefix | Purpose | Receives |
|---|---|---|---|
| Before | before<MethodName> |
Modify input arguments | Subject + original args |
| After | after<MethodName> |
Modify return value | Subject + result (+ original args) |
| Around | around<MethodName> |
Wrap entire execution | Subject + $proceed callable + original args |