{"id":15991,"date":"2018-06-12T13:31:57","date_gmt":"2018-06-12T11:31:57","guid":{"rendered":"https:\/\/belvg.com\/blog\/?p=15991"},"modified":"2021-02-18T09:25:58","modified_gmt":"2021-02-18T07:25:58","slug":"designing-complex-solutions-using-plugins-in-magento-2","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html","title":{"rendered":"How to Use Plugins in Magento 2"},"content":{"rendered":"\n<p>Magento 2 Plugin (Interceptor) is a class that allows you to change the behavior of other classes&rsquo; methods by calling custom code before, after, or instead of calling specific methods. This reduces the probability of conflicts between different code sections representing the same functionality.<\/p>\n<p><!--more--><\/p>\n<h2><strong><span style=\"color: #000000;\">Plugin Configuration<\/span><\/strong><\/h2>\n<pre class=\"lang:xhtml decode:true\">\/app\/code\/Vendor\/Module\/etc\/di.xml\r\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"..\/..\/..\/..\/..\/lib\/internal\/Magento\/Framework\/ObjectManager\/etc\/config.xsd\"&gt;\r\n&nbsp;&nbsp;&lt;type name=\"{ObservedType}\"&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;plugin name=\"{PluginName}\" type=\"{PluginClassName}\" sortOrder=\"1\" disabled=\"false\"\/&gt;\r\n&nbsp;&nbsp;&nbsp;&lt;\/type&gt;\r\n&lt;\/config&gt;<\/pre>\n<p>, where:<\/p>\n<p><em>{ObservedType}&nbsp;<\/em>&mdash; the name of the class, whose method is to be changed;<\/p>\n<p><em>{PluginName}<\/em>&nbsp;&mdash; the name of the plugin;<\/p>\n<p><em>{PluginClassName}<\/em>&nbsp;&mdash; plugin&rsquo;s class name;<\/p>\n<p><em>sortOrder&nbsp;<\/em>&mdash; plugin&rsquo;s calling order;<\/p>\n<p><em>disabled<\/em>&nbsp;&mdash; the ability to make Magento ignore the plugin while leaving its configuration in place.<\/p>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/belvg.com\/migration-to-magento-2\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/06\/migration-to-magento-2.png\" width=\"100\" height=\"100\" alt=\"migration to magento 2\" class=\"module_image\" title=\"How to Use Plugins in Magento 2\"><div class=\"module_content_part\"><h3 class=\"title\">Magento 2 Migration<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento 2 Migration<\/p><a href=\"https:\/\/belvg.com\/migration-to-magento-2\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n<h2><strong><span style=\"color: #000000;\">Plugin Methods<\/span><\/strong><\/h2>\n<h4><strong><span style=\"color: #000000;\">Before Methods<\/span><\/strong><\/h4>\n<p><i><span style=\"font-weight: 400;\">Before<\/span><\/i> <i><span style=\"font-weight: 400;\">methods<\/span><\/i><span style=\"font-weight: 400;\"> allow modifying the target class method arguments before this method is called.<\/span><\/p>\n<pre class=\"lang:php decode:true\">Namespace Vendor\\Module\\Plugin;\r\nclass Plugin\r\n{\r\n&nbsp;&nbsp;&nbsp;public function beforeMethodName(\\Vendor\\Module\\Model\\TargetClass $subject, $arg1, $arg2, $arg3 = null)\r\n&nbsp;&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return [$arg1, $arg2, $arg3];\r\n&nbsp;&nbsp;&nbsp;}\r\n}<\/pre>\n<p>The name of the plugin method is concatenated &lsquo;<em>before<\/em>&lsquo; and the name of the method, whose arguments are to be changed. The first argument of this method is the class whose method is called. The remaining arguments must match the arguments of the called method, including default values.<\/p>\n<p><em>Before methods<\/em> must return an array of arguments.<\/p>\n<h4><span style=\"color: #000000;\"><strong>After Methods<\/strong><\/span><\/h4>\n<p><em>After methods<\/em> allow modifying the result of the target method.<\/p>\n<pre class=\"lang:php decode:true\">Namespace Vendor\\Module\\Plugin;\r\nclass Plugin\r\n{\r\npublic function afterMethodName(\\Vendor\\Module\\Model\\TargetClass $subject, $result)\r\n{\r\nreturn $result;\r\n}\r\n}<\/pre>\n<p>The first argument is the target class instance (like in before methods), the second is the return value of the original method.<\/p>\n<h4><strong><span style=\"color: #000000;\">Around Methods<\/span><\/strong><\/h4>\n<pre class=\"lang:php decode:true\">Namespace Vendor\\Module\\Plugin;\r\nclass Plugin\r\n{\r\npublic function aroundMethodName(\\Vendor\\Module\\Model\\TargetClass $subject, callable $proceed, $arg1, $arg2, $arg3)\r\n{\r\n$result = $proceed();\r\nreturn $result;\r\n}\r\n}<\/pre>\n<p><em>Around methods<\/em> allow you to execute code both before and after the target method in one place.<\/p>\n<p><em>$proceed<\/em> argument is PHP closure, which in turn calls the target method.<\/p>\n<p>Such methods allow you to completely replace the target method.<\/p>\n<h2><strong><span style=\"color: #000000;\">Limitations<\/span><\/strong><\/h2>\n<p>Unlike Magento 1 class rewrites, plugins do not inherit the target class, which facilitates the peaceful coexistence of several plugins that change the same method. But for the same reason, plugins have certain limitations.<\/p>\n<p>Plugins cannot be used with:<\/p>\n<ol>\n<li>Final methods and classes<\/li>\n<li>Protected\/private methods<\/li>\n<li>Static methods<\/li>\n<li>__construct methods<\/li>\n<li>Virtual types<\/li>\n<li>Objects that are instantiated before Magento\\Framework\\Interception is bootstrapped<\/li>\n<\/ol>\n<div class=\"content_sales_info\" style=\"background-image: url(https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/03\/Sales_background.png\"><img width=\"65\" height=\"65\" src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/03\/Igor-Dragun1.png\" alt=\"Igor Dragun\" title=\"How to Use Plugins in Magento 2\"><div class=\"content_part\"><h3 class=\"title\">Partner With Us <\/h3><span class=\"sales_content_text\">Let's discuss how to grow your business. Get a Free Quote.<\/span><\/div> <a class=\"call-to-action\" href=\"https:\/\/belvg.com\/contact?utm_source=blog&amp;utm_campaign=sales_block&amp;utm_content=middle\" target=\"_blank\" rel=\"noopener\">Talk to Igor<\/a><\/div>\n<h2><strong><span style=\"color: #000000;\">Plugin Sorting<\/span><\/strong><\/h2>\n<p>Plugin <em>sortOrder<\/em> parameter allows you to determine in which order the plugin methods will be called in case multiple plugins are observing the same method.<\/p>\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td><span style=\"font-weight: 400;\">Plugin1<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Plugin2<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Plugin3<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">sort order<\/span><\/td>\n<td><span style=\"font-weight: 400;\">10<\/span><\/td>\n<td><span style=\"font-weight: 400;\">20<\/span><\/td>\n<td><span style=\"font-weight: 400;\">30<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">before<\/span><\/td>\n<td><span style=\"font-weight: 400;\">beforeMethod()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">beforeMethod()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">beforeMethod()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">around<\/span><\/td>\n<td><\/td>\n<td><span style=\"font-weight: 400;\">aroundMethod()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">aroundMethod()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">after<\/span><\/td>\n<td><span style=\"font-weight: 400;\">afterMethod()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">afterMethod()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">afterMethod()<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In this case, the processing of plugins will occur in the following order:<\/p>\n<ol>\n<li>Plugin1::beforeMethod()<\/li>\n<li>Plugin2::beforeMethod()<\/li>\n<li>Plugin2::aroundMethod() (Magento calls the first half until callable)\n<ol>\n<li>Plugin3::beforeMethod()<\/li>\n<li>Plugin3::aroundMethod() (Magento calls the first half until callable)\n<ul>\n<li>TargetClass::method()<\/li>\n<\/ul>\n<\/li>\n<li>Plugin3::aroundMethod() (Magento calls the second half after callable)<\/li>\n<li>Plugin3::afterMethod()<\/li>\n<\/ol>\n<\/li>\n<li>Plugin2::aroundMethod() (Magento calls the second half after callable)<\/li>\n<li>Plugin1::afterMethod()<\/li>\n<li>Plugin2::afterMethod()<\/li>\n<\/ol>\n<p>That is it regarding plugins in Magento 2, hope it was helpful. If you have any questtions on the article, please leave them in the comment section below.<\/p>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/store.belvg.com\/\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/06\/Magento-store.belvg_.com_.png\" width=\"481\" height=\"480\" alt=\"Magento store.belvg.com\" class=\"module_image\" title=\"How to Use Plugins in Magento 2\"><div class=\"module_content_part\"><h3 class=\"title\">Magento Extensions<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento Extensions<\/p><a href=\"https:\/\/store.belvg.com\/\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"Designing complex solutions using plugins in Magento 2","protected":false},"author":82,"featured_media":16000,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[474,389,524],"tags":[],"class_list":["post-15991","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-ecommerce","category-magento2-development","category-magento-speed-optimization","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Learn to design complex solutions using the plugins in Magento 2. Plugin methods, plugin configuration, plugin limitations and plugin sorting in Magento 2.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Andrey Litvin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#article\",\"name\":\"How to Use Plugins in Magento 2 | BelVG Blog\",\"headline\":\"How to Use Plugins in Magento 2\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/How_to_Design_Complex_Solutions.jpg\",\"width\":770,\"height\":433},\"datePublished\":\"2018-06-12T13:31:57+02:00\",\"dateModified\":\"2021-02-18T09:25:58+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":6,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#webpage\"},\"articleSection\":\"ECOMMERCE, Magento 2 Development, Magento Speed Optimization, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"position\":2,\"name\":\"Magento 2 Development\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#listItem\",\"name\":\"How to Use Plugins in Magento 2\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#listItem\",\"position\":3,\"name\":\"How to Use Plugins in Magento 2\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin\",\"name\":\"Andrey Litvin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Andrey Litvin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html\",\"name\":\"How to Use Plugins in Magento 2 | BelVG Blog\",\"description\":\"Learn to design complex solutions using the plugins in Magento 2. Plugin methods, plugin configuration, plugin limitations and plugin sorting in Magento 2.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/How_to_Design_Complex_Solutions.jpg\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html\\\/#mainImage\",\"width\":770,\"height\":433},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/designing-complex-solutions-using-plugins-in-magento-2.html#mainImage\"},\"datePublished\":\"2018-06-12T13:31:57+02:00\",\"dateModified\":\"2021-02-18T09:25:58+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How to Use Plugins in Magento 2 | BelVG Blog","description":"Learn to design complex solutions using the plugins in Magento 2. Plugin methods, plugin configuration, plugin limitations and plugin sorting in Magento 2.","canonical_url":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#article","name":"How to Use Plugins in Magento 2 | BelVG Blog","headline":"How to Use Plugins in Magento 2","author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/06\/How_to_Design_Complex_Solutions.jpg","width":770,"height":433},"datePublished":"2018-06-12T13:31:57+02:00","dateModified":"2021-02-18T09:25:58+02:00","inLanguage":"en-US","commentCount":6,"mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#webpage"},"articleSection":"ECOMMERCE, Magento 2 Development, Magento Speed Optimization, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","position":2,"name":"Magento 2 Development","item":"https:\/\/belvg.com\/blog\/category\/magento2-development","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#listItem","name":"How to Use Plugins in Magento 2"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#listItem","position":3,"name":"How to Use Plugins in Magento 2","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author","url":"https:\/\/belvg.com\/blog\/author\/andrey-litvin","name":"Andrey Litvin","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g","width":96,"height":96,"caption":"Andrey Litvin"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#webpage","url":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html","name":"How to Use Plugins in Magento 2 | BelVG Blog","description":"Learn to design complex solutions using the plugins in Magento 2. Plugin methods, plugin configuration, plugin limitations and plugin sorting in Magento 2.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/06\/How_to_Design_Complex_Solutions.jpg","@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html\/#mainImage","width":770,"height":433},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html#mainImage"},"datePublished":"2018-06-12T13:31:57+02:00","dateModified":"2021-02-18T09:25:58+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"15991","title":"How to Use Plugins in Magento 2  | #site_title","description":"Learn to design complex solutions using the plugins in Magento 2. Plugin methods, plugin configuration, plugin limitations and plugin sorting in Magento 2.","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:08","updated":"2026-11-03 18:37:08"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento2-development\" title=\"Magento 2 Development\">Magento 2 Development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to Use Plugins in Magento 2\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento 2 Development","link":"https:\/\/belvg.com\/blog\/category\/magento2-development"},{"label":"How to Use Plugins in Magento 2","link":"https:\/\/belvg.com\/blog\/designing-complex-solutions-using-plugins-in-magento-2.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/15991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/82"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=15991"}],"version-history":[{"count":1,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/15991\/revisions"}],"predecessor-version":[{"id":25893,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/15991\/revisions\/25893"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/16000"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=15991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=15991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=15991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}