{"id":43049,"date":"2016-04-01T18:49:10","date_gmt":"2016-04-01T18:49:10","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=43049"},"modified":"2026-01-21T14:57:36","modified_gmt":"2026-01-21T14:57:36","slug":"magento2-use-plugins","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/","title":{"rendered":"Magento2 \u2013 Create and Use Plugins"},"content":{"rendered":"<p>In this blog we will discuss about new feature of <a href=\"https:\/\/store.webkul.com\/Magento-2.html\">Magento 2 Plugins<\/a><strong>. <\/strong>There is a design pattern called <strong>&#8216;Interception&#8217;<\/strong> used in Plugins.<\/p>\n<p>Interception is inserting code dynamically without changing the original class behaviour. In this process code is dynamically inserted between the calling code and the target object.<\/p>\n<p>You can check the overview in the video below \u2014<\/p>\n<p><iframe title=\"Magento Meetup New Delhi- Magento 2 Plugins\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/PWDS2j-M2wU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen loading=\"lazy\"><\/iframe><\/p>\n<h2>Types of Magento 2 Plugins<\/h2>\n<p>We can create and use three types of Magento 2 Plugins.<\/p>\n<ul>\n<li>Before listener Plugin<\/li>\n<li>After listener Plugin<\/li>\n<li>Around listener Plugin<\/li>\n<\/ul>\n<h3>1. Before Listener<\/h3>\n<p>Before listeners are used whenever we want to change the arguments of an original method or want to add some behavior before an original method is called.<\/p>\n<p>We will use before listeners to change behavior of addProduct method of Magento\\Checkout\\Model\\Cart.<\/p>\n<p>This method is called whenever we add product to cart.<\/p>\n<p>Original Method is<br \/><strong>public function addProduct($productInfo, $requestInfo = null)<\/strong><\/p>\n<p>To use Plugins first of all we have to define it in di.xml.<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\"?&gt;\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\"&gt;\n\t&lt;type name=\"Magento\\Checkout\\Model\\Cart\"&gt;\n\t\t&lt;plugin name=\"WebkulCart\" type=\"Webkul\\Test\\Model\\Cart\" sortOrder=\"1\" \/&gt;\n\t&lt;\/type&gt;\n&lt;\/config&gt;<\/pre>\n<p>Now create file Cart.php in folder &#8216;Webkul\\Test\\Model&#8217;.<\/p>\n<p>Before listener is called by adding prefix &#8216;before&#8217; to the method name and setting first letter of original method to capital.<br \/>Now method addProduct will become beforeAddProduct.<\/p>\n<pre class=\"brush:php\">&lt;?php\n\t\n\tnamespace Webkul\\Test\\Model;\n\n\tclass Cart\n\t{\n\t\tpublic function beforeAddProduct(\n\t\t\t\\Magento\\Checkout\\Model\\Cart $subject,\n\t\t\t$productInfo,\n\t\t\t$requestInfo = null\n\t\t) {\n\t\t\t$requestInfo['qty'] = 10; \/\/ increasing quantity to 10\n\t\t\treturn array($productInfo, $requestInfo);\n\t\t}\n\t}<\/pre>\n<p><strong>\u00a0If there are any arguments, the method should return an array of those arguments. If the method does not change the argument for the observed method, it should return a <code class=\"language-plaintext highlighter-rouge\">null<\/code>\u00a0value.<\/strong><\/p>\n<p>Here we are changing parameters. We set quantity to 10. Now it will always add 10 quantities of the product whenever we add product to cart.<\/p>\n<p>So we will use before listener when we want to change parameter of an method.<br \/><img decoding=\"async\" class=\"alignnone size-large wp-image-44767\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/2-2-1200x537.png\" alt=\"Plugins\" width=\"1200\" height=\"537\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/2-2-1200x537.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/2-2-250x112.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/2-2-300x134.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/2-2-768x344.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/2-2-604x270.png 604w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/2-2.png 1371w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><br \/><img decoding=\"async\" class=\"alignnone size-large wp-image-44768\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/3-2-1200x675.png\" alt=\"Plugins\" width=\"1200\" height=\"675\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/3-2-1200x675.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/3-2-250x141.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/3-2-300x169.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/3-2-768x432.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/3-2.png 1337w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/p>\n<h3>2. After Listener<\/h3>\n<p>After listeners are used when we want to change values returned by an original method or want to add some behavior after an original method is called.<\/p>\n<p>We will use after listeners to change behavior of getName method of Magento\\Catalog\\Model\\Product.<\/p>\n<p>This method returns the name of Product.<\/p>\n<p>Original Method is<\/p>\n<p><strong>public function getName()<\/strong><\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\"?&gt;\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\"&gt;\n\t&lt;type name=\"Magento\\Catalog\\Model\\Product\"&gt;\n\t\t&lt;plugin name=\"WebkulCart\" type=\"Webkul\\Test\\Model\\Product\" sortOrder=\"1\" \/&gt;\n\t&lt;\/type&gt;\n&lt;\/config&gt;<\/pre>\n<p>Now create file Product.php in folder &#8216;Webkul\\Test\\Model&#8217;.<\/p>\n<p>Magento calls an after listener by adding the prefix <code data-start=\"293\" data-end=\"300\">after<\/code> to the method name and capitalizing the first letter of the original method.<\/p>\n<p>Now method getName will become afterGetName.<\/p>\n<pre class=\"brush:php\">&lt;?php\n\t\n\tnamespace Webkul\\Test\\Model;\n\n\tclass Product\n\t{\n\t\tpublic function afterGetName(\\Magento\\Catalog\\Model\\Product $subject, $result) {\n\t\t\treturn \"Apple \".$result; \/\/ Adding Apple in product name\n\t\t}\n\t}<\/pre>\n<p><img decoding=\"async\" class=\"alignnone size-large wp-image-44783\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/6-2-1200x556.png\" alt=\"Plugins\" width=\"1200\" height=\"556\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/6-2-1200x556.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/6-2-250x116.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/6-2-300x139.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/6-2-768x356.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/6-2.png 1363w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><br \/><img decoding=\"async\" class=\"alignnone size-large wp-image-44781\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/5-2-1200x630.png\" alt=\"Plugins\" width=\"1200\" height=\"630\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/5-2.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/5-2-250x131.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/5-2-300x158.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/04\/5-2-768x403.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/p>\n<h3>3. Around Listener<\/h3>\n<p>Around listeners are used when we want to change both the arguments and the returned values of an original method or add some behavior before and after an original method is called.<\/p>\n<p>We will use around listeners to change behavior of addProduct method of Magento\\Checkout\\Model\\Cart.<\/p>\n<p>Magento calls an around listener by prefixing the method name with <code data-start=\"560\" data-end=\"568\">around<\/code> and capitalizing the first letter of the original method.<br \/>Now method addProduct will become aroundAddProduct.<\/p>\n<pre class=\"brush:php\">&lt;?php\n\t\n\tnamespace Webkul\\Test\\Model;\n\n\tclass Cart\n\t{\n\t\tpublic function aroundAddProduct(\n\t\t\t\\Magento\\Checkout\\Model\\Cart $subject,\n\t\t\t\\Closure $proceed,\n\t\t\t$productInfo,\n\t\t\t$requestInfo = null\n\t\t) {\n\t\t\t$requestInfo['qty'] = 10; \/\/ setting quantity to 10\n\t\t\t$result = $proceed($productInfo, $requestInfo);\n\t\t\t\/\/ change result here\n\t\t\treturn $result;\n\t\t}\n\t}<\/pre>\n<p>The around listener method forms the return value by passing the parameters that follow the <code data-start=\"748\" data-end=\"758\">$closure<\/code> parameter in the method definition to the <code data-start=\"801\" data-end=\"811\">$closure<\/code> function call in sequential order.<\/p>\n<p>That&#8217;s all for Magento 2 <strong>Plugin System<\/strong>.<br \/>If you have any query please comment below.<\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog we will discuss about new feature of Magento 2 Plugins. There is a design pattern called &#8216;Interception&#8217; used in Plugins. Interception is inserting code dynamically without changing the original class behaviour. In this process code is dynamically inserted between the calling code and the target object. You can check the overview in <a href=\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":21,"featured_media":61035,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[2878,2070,2892,2893],"class_list":["post-43049","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento2","tag-create-plugin","tag-magento2","tag-plugins-in-magento2","tag-use-plugins"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create and Use Magento 2 Plugins to Override Functions<\/title>\n<meta name=\"description\" content=\"Leverage Magento 2 plugins to customize store behavior by overriding functions. Extend core functionality without altering core code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create and Use Magento 2 Plugins to Override Functions\" \/>\n<meta property=\"og:description\" content=\"Leverage Magento 2 plugins to customize store behavior by overriding functions. Extend core functionality without altering core code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rahul0989\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-01T18:49:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-21T14:57:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rahul Mahto\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rahul Mahto\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/\"},\"author\":{\"name\":\"Rahul Mahto\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3002e6bca8362f6cf1c61b2663496c4f\"},\"headline\":\"Magento2 \u2013 Create and Use Plugins\",\"datePublished\":\"2016-04-01T18:49:10+00:00\",\"dateModified\":\"2026-01-21T14:57:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/\"},\"wordCount\":494,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png\",\"keywords\":[\"Create Plugin\",\"Magento2\",\"Plugins in Magento2\",\"Use Plugins\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/\",\"url\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/\",\"name\":\"Create and Use Magento 2 Plugins to Override Functions\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png\",\"datePublished\":\"2016-04-01T18:49:10+00:00\",\"dateModified\":\"2026-01-21T14:57:36+00:00\",\"description\":\"Leverage Magento 2 plugins to customize store behavior by overriding functions. Extend core functionality without altering core code.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png\",\"width\":825,\"height\":260,\"caption\":\"New Product Type\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento2 \u2013 Create and Use Plugins\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3002e6bca8362f6cf1c61b2663496c4f\",\"name\":\"Rahul Mahto\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b0def172ef24ea3f7319500afbb65af8012023ba5c143982a4c958b2fb58ee0d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b0def172ef24ea3f7319500afbb65af8012023ba5c143982a4c958b2fb58ee0d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Rahul Mahto\"},\"sameAs\":[\"http:\/\/webkul.com\",\"https:\/\/www.facebook.com\/rahul0989\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/rahul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create and Use Magento 2 Plugins to Override Functions","description":"Leverage Magento 2 plugins to customize store behavior by overriding functions. Extend core functionality without altering core code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/","og_locale":"en_US","og_type":"article","og_title":"Create and Use Magento 2 Plugins to Override Functions","og_description":"Leverage Magento 2 plugins to customize store behavior by overriding functions. Extend core functionality without altering core code.","og_url":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_author":"https:\/\/www.facebook.com\/rahul0989","article_published_time":"2016-04-01T18:49:10+00:00","article_modified_time":"2026-01-21T14:57:36+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png","type":"image\/png"}],"author":"Rahul Mahto","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Rahul Mahto","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/"},"author":{"name":"Rahul Mahto","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3002e6bca8362f6cf1c61b2663496c4f"},"headline":"Magento2 \u2013 Create and Use Plugins","datePublished":"2016-04-01T18:49:10+00:00","dateModified":"2026-01-21T14:57:36+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/"},"wordCount":494,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png","keywords":["Create Plugin","Magento2","Plugins in Magento2","Use Plugins"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/magento2-use-plugins\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/","url":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/","name":"Create and Use Magento 2 Plugins to Override Functions","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png","datePublished":"2016-04-01T18:49:10+00:00","dateModified":"2026-01-21T14:57:36+00:00","description":"Leverage Magento 2 plugins to customize store behavior by overriding functions. Extend core functionality without altering core code.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/magento2-use-plugins\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/Magneto-Code-Snippet.png","width":825,"height":260,"caption":"New Product Type"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/magento2-use-plugins\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Magento2 \u2013 Create and Use Plugins"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3002e6bca8362f6cf1c61b2663496c4f","name":"Rahul Mahto","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b0def172ef24ea3f7319500afbb65af8012023ba5c143982a4c958b2fb58ee0d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b0def172ef24ea3f7319500afbb65af8012023ba5c143982a4c958b2fb58ee0d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Rahul Mahto"},"sameAs":["http:\/\/webkul.com","https:\/\/www.facebook.com\/rahul0989"],"url":"https:\/\/webkul.com\/blog\/author\/rahul\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/43049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=43049"}],"version-history":[{"count":60,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/43049\/revisions"}],"predecessor-version":[{"id":523081,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/43049\/revisions\/523081"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/61035"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=43049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=43049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=43049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}