0
  • I have one Observer in my custom module.
  • I want to create Plugin for that observer.

How can I achieve that ?

1

You can right controller or observer path in your di.xml file as per the syntax mention here :

<config>
    <type name="{ObservedType}">
        <plugin name="{pluginName}" type="{PluginClassName}" sortOrder="1" disabled="false"/>
    </type>
</config>
  • type name: Enter name of a class or interface that needs to be followed.
  • plugin name: An arbitrary plugin name that identifies a plugin. Also used to merge the configurations for the plugin.
  • plugin type: Fill the name of a plugin’s class or its virtual type. You can refer the following naming convention for this field: \Vendor\Module\Plugin\Plugin.
1

Just add to di.xml your plugin.

<type name="Your\Observer\Namespace">
    <plugin name="your_plugin_name" type="Your\Plugin\Class" />
</type>

Then you can create methods like beforeExecute afterExecute etc.

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.