magento-module-development

Build Magento 2 modules with dependency injection, service contracts, plugins, and declarative schema.

3|1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/tomtoto757/ecomm-ai-team --skill magento-module-development-tomtoto757
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: magento-module-development
Source: https://github.com/tomtoto757/ecomm-ai-team/tree/main/skills/platform-integrations-infrastructure/finsilabs/platform-magento/magento-module-development
Command: npx skills add https://github.com/tomtoto757/ecomm-ai-team --skill magento-module-development-tomtoto757

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Extending Magento 2 without breaking core functionality requires deep knowledge of its module architecture, DI container, and event system. This Skill guides the creation of custom Magento 2 modules that follow platform conventions, avoiding class rewrites, legacy schema scripts, and direct Object Manager usage. ## Core Features & Use Cases - Module Scaffolding: Generates the complete app/code/Vendor/Module skeleton with registration.php, module.xml sequences, and proper namespace structure. - Service Contracts & DI: Implements Api/ interfaces, repositories, and di.xml preferences so other modules and REST/GraphQL integrations can depend on stable contracts. - Plugins, Observers & Schema: Covers before/after/around plugins, event observers with safe error handling, declarative db_schema.xml tables, and webapi.xml REST endpoints. - Use Case: A retailer needs a loyalty program module tracking member tiers and points. Use this Skill to scaffold the module, define the membership repository interface, create the database table declaratively, and expose it via REST API. ## Quick Start Create a Magento 2 module called Acme_Loyalty with a membership entity, service contracts, declarative schema, and a REST endpoint to list members.

Frequently Asked Questions about magento-module-development

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

FAQPage Schema
How do I create a custom Magento 2 module?▼

Create a directory under app/code/Vendor/Module containing registration.php with ComponentRegistrar::register() and etc/module.xml declaring the module name and sequence dependencies. Then add your models, configuration, and run bin/magento setup:upgrade to register it.

Should I use plugins or preferences to override Magento core behavior?▼

Use plugins (interceptors) instead of preferences whenever possible. Plugins are composable so multiple modules can modify the same method, while preferences rewrite the entire class and cause conflicts between modules.

How do I add a custom database table in Magento 2?▼

Define the table in etc/db_schema.xml using declarative schema with columns, constraints, and indexes, then run bin/magento setup:upgrade. Generate the whitelist file with setup:db-declaration:generate-whitelist to allow future schema changes.

Why does Magento say my class does not exist after adding it?▼

This usually means DI compilation has not run. Execute bin/magento setup:di:compile and bin/magento cache:flush, and verify the PHP namespace exactly matches the directory path under app/code.

Can an observer exception block checkout in Magento 2?▼

Yes, an uncaught exception in an observer can interrupt critical flows like order placement. Wrap observer logic in try/catch, log errors via LoggerInterface, and never re-throw exceptions from the execute() method.

How do I expose a custom entity through the Magento REST API?▼

Define routes in etc/webapi.xml mapping URLs to your repository interface methods, and bind the interface to its implementation with a preference in di.xml. The service class attribute must reference the interface, not a concrete class.