magento-plugins-interceptors

Create Magento 2 before/after/around plugins to intercept and modify method execution.

35|16|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/OrcaQubits/agentic-commerce-claude-plugins --skill magento-plugins-interceptors
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: magento-plugins-interceptors
Source: https://github.com/OrcaQubits/agentic-commerce-claude-plugins/tree/main/magento2-commerce/skills/magento-plugins-interceptors
Command: npx skills add https://github.com/OrcaQubits/agentic-commerce-claude-plugins --skill magento-plugins-interceptors

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill allows developers to modify the behavior of Magento 2 classes without directly altering their code or using traditional inheritance, streamlining customizations and extensions.

Core Features & Use Cases

  • Method Interception: Intercept public method calls on classes using before, after, or around plugins.
  • Argument/Return Modification: Modify method arguments before execution or return values after execution.
  • Execution Wrapping: Wrap entire method executions to add custom logic or control flow.
  • Use Case: You need to add a custom validation rule to the save method of a core Magento product model. Instead of rewriting the model, you can create a beforeSave plugin to add your validation logic.

Quick Start

Use the magento-plugins-interceptors skill to create a 'before' plugin for the save method of the Magento\Catalog\Model\Product class.

Frequently Asked Questions about magento-plugins-interceptors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I modify Magento 2 class behavior without using inheritance?

Magento 2 plugins (interceptors) modify class behavior without inheritance by using before, after, and around methods to intercept public calls and change arguments or return values via Dependency Injection.

What is the difference between before, after, and around plugins in Magento 2?

Before plugins change method arguments before execution, after plugins modify return values after execution, and around plugins wrap the entire method execution to control the original method call flow and add custom logic.

How do I add custom validation to a Magento 2 product save method?

Create a beforeSave plugin for the Magento\Catalog\Model\Product class to intercept the save method and inject your custom validation logic without rewriting the core model.

Do I need to configure XML to declare Magento 2 interceptors?

Yes, declaring Magento 2 plugins requires XML configuration within the Dependency Injection system to specify the target class and the plugin class implementing the interception logic.

Can I use Magento 2 plugins to extend third-party module functionality?

Yes, Magento 2 plugins can intercept public methods on third-party module classes, allowing you to modify their behavior and extend functionality without altering the original extension code or using inheritance.

What are the limitations of using Magento 2 plugins for extension development?

Magento 2 plugins only intercept public methods and require understanding of the Dependency Injection system and XML configuration, making them unsuitable for modifying private methods or non-public class members.