Skip to content

Plugins

Global plugins list

Plugins list

The plugins page allows you to view all the plugins in your project.

Module plugins list

In the module detail view, you can see the plugins declared by this module.

INFO

This list does not include (yet) plugins declared by other modules that affect this module.

Module plugin creation

You can create a new plugin by clicking Generate > Plugin button from the module detail view.

Plugin create

The module plugin creation wizard includes the following features:

  • Auto-generate the plugin name (for di.xml)
  • Given a target module, auto-complete the list of available pluggable classes and methods
  • Auto-generate the plugin class with the correct method signature

The following files are created/updated in app/code/Vendor/Module when you create a new plugin:

  • etc/di.xml: created if it does not exist, or updated with the new plugin declaration
  • <plugin-directory>/PluginName.php: created with the new plugin class and method

WARNING

If the plugin class already exists, it will completely be overwritten.

Example of a generated plugin

PHP class

php
<?php

declare(strict_types=1);

namespace MB\Test\Plugin;

use Magento\Store\Api\GroupRepositoryInterface;

class TestPlugin
{
    public function afterGetList(GroupRepositoryInterface $subject, $result)
    {
        // Add your code here
    }
}

etc/di.xml

xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
  <type name="Magento\Store\Api\GroupRepositoryInterface">
    <plugin name="mb_test_test_plugin" type="MB\Test\Plugin\TestPlugin" sortOrder="10"/>
  </type>
</config>

Released under the MIT License.
This project is not affiliated with, endorsed by, or sponsored by Adobe Inc. "Magento" and "Adobe Commerce" are trademarks of Adobe Inc.
All trademarks and registered trademarks are the property of their respective owners.