I am trying to create a simple module and I can't find the propose of the attribute name and type inside the tag type and plugin in di.xml. can anyone describe attribute name used in plugin?

<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <type name="???">
        <plugin name="???" type="???" sortOrder="1"/>

The documentation is not so clear for a beginner.

    <type name="{ObservedType}">
      <plugin name="{pluginName}" type="{PluginClassName}" sortOrder="1" disabled="false" />

You must specify these elements:

  • ObservedType : A class or interface which the plugin observes.(core file path)
  • pluginName : An arbitrary plugin name that identifies a plugin. Also used to merge the configurations for the plugin.(you can set any unique name )
  • PluginClassName : The name of a plugin’s class or its virtual type. Use the following naming convention when you specify this element: \Vendor\Module\Plugin\(extension file path in which you are overriding).

A small explanation can be found here:


Besides that you can also generate Plugins, see the following example module:


This example module contains the following di.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\Catalog\Model\Product">
        <plugin disabled="false" name="Vendor_ModuleName_Plugin_Magento_Catalog_Model_Product" sortOrder="10" type="Vendor\ModuleName\Plugin\Magento\Catalog\Model\Product"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.