Contents
- 1. Two ways to extend Magento
- 2. Preferences: replacing a class via di.xml
- 3. Why Preferences are problematic
- 4. Plugins (interceptors): the Interceptor Pattern
- 5. Before plugin: modifying arguments
- 6. After plugin: modifying the return value
- 7. Around plugin: full control (and risks)
- 8. Plugin ordering and conflicts
- 9. Plugin limits: what plugins can't do
- 10. Decision matrix: Preference vs. Plugin vs. Observer
One of the most common questions in Magento code reviews: "Should I use a Preference or a Plugin?" The answer is almost always Plugin, but why, and which type? This deep dive shows the exact differences, the internal mechanisms, and