Creates a Plugin

Plugins are designed to overwrite core Magento methods or methods from other 3rd party modules.

You can choose to change it before, after, or around the original method is called.


Change the product name to show pipes before and after the name.

Input for the plugin form

  • classname: MagentoCatalogModelProduct
  • methodname: getName
  • plugintype: After
public function afterGetName(
        Magento\Catalog\Model\Product $subject,
        return '|'.$result.'|';

Use the Plugin snippet in the Magento 2 module creator.