magento-plugin

Create Magento 2 before, after, and around plugins with di.xml configuration.

32|3|Updated Feb 20, 2026
One-click install
npx skills add https://github.com/furan917/magento-ai-toolkit --skill magento-plugin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: magento-plugin
Source: https://github.com/furan917/magento-ai-toolkit/tree/main/skills/magento-plugin
Command: npx skills add https://github.com/furan917/magento-ai-toolkit --skill magento-plugin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Create Magento 2 plugins (interceptors) to modify core or third-party method behaviour without editing vendor code. This approach keeps core/vendor integrity while enabling targeted behavior changes.

Core Features & Use Cases

  • Before/After/Around plugins to modify input, output, or wrap original methods on Magento classes.
  • Safe integration with di.xml configuration and proper scope placement to minimize conflicts.
  • Real-world scenarios: intercept product methods like getName or save flows to implement custom business rules without changing vendor code.

Quick Start

Paste this skill as a system prompt and describe the method you want to intercept.

Frequently Asked Questions about magento-plugin

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

FAQPage Schema
How do I modify Magento 2 core method behavior without editing vendor code?

Magento 2 plugins (interceptors) modify core or third-party method behavior without touching vendor code. You create before, after, or around plugins and register them via di.xml configuration to safely intercept public methods.

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

Magento 2 before plugins change input arguments, after plugins modify return values, and around plugins wrap the original method entirely. Choosing the least invasive plugin type minimizes conflicts and preserves core functionality.

How do I configure di.xml for a Magento 2 plugin interceptor?

You configure a Magento 2 plugin in di.xml by defining a type node, adding a plugin child node with a name, class, and sortOrder. Proper scope placement in etc/frontend/di.xml or etc/adminhtml/di.xml minimizes conflicts.

Can I intercept Magento 2 product methods like getName or save flows using plugins?

Yes, Magento 2 plugins can intercept public methods on product classes like getName or save flows. This enables you to implement custom business rules in both frontend and admin contexts without modifying vendor code.

When should I use an around plugin versus before or after plugins in Magento 2?

Use around plugins in Magento 2 only when you need to wrap the original method entirely to change both input and output. Before and after plugins are less invasive and preferred when you only need to modify arguments or return values.

What are the limitations of using Magento 2 interceptors for modifying methods?

Magento 2 interceptors only work on public methods and require proper di.xml configuration. You must manage sortOrder spacing carefully to avoid conflicts and ensure safe integration across frontend and admin scopes.