{"id":200603,"date":"2019-10-21T05:03:40","date_gmt":"2019-10-21T05:03:40","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=200603"},"modified":"2019-12-26T14:57:13","modified_gmt":"2019-12-26T14:57:13","slug":"how-to-override-a-component-in-shopware-6","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/","title":{"rendered":"How to override a Component in Shopware 6"},"content":{"rendered":"\n<p> In this article, we will look into modules which can be override and use in our custom module in Shopware 6. I hope you know the directory structure of Shopware 6 plugin, if you don&#8217;t know, see here- <a href=\"https:\/\/docs.shopware.com\/en\/shopware-platform-dev-en\/internals\/directory-structure\">https:\/\/docs.shopware.com\/en\/shopware-platform-dev-en\/internals\/directory-structure<\/a>.<\/p>\n\n\n\n<p> <strong>Setup :<\/strong><br> You can create a new plugin for shopware 6. To learn creating  a plugin at first. There is a <a href=\"https:\/\/docs.shopware.com\/en\/shopware-platform-dev-en\/internals\/plugins\/plugin-quick-start\">link<\/a>:-<br><\/p>\n\n\n\n<p>The main entry point to customize the administration via plugin is <code>main.js<\/code> file. File is placed into <code>&lt;plugin root&gt;\/src\/Resources\/administration<\/code> directory. It will automatically found  by shopware 6. If you don<\/p>\n\n\n\n<p>In <code>main.js<\/code> file, override Vue Component using override method of an <code>ComponentFactory<\/code>.<\/p>\n\n\n\n<p>The first parameter is component to override and second parameter is  new twig template for this component.<br><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">import template from &#039;.\/src\/extension\/sw-order-detail\/sw-order-detail.html.twig&#039;;&lt;br&gt;&lt;\/code&gt;&lt;br&gt;&lt;code&gt;Component.override(&#039;sw-order-detail&#039;, {&lt;br&gt; template,&lt;br&gt; });<\/pre>\n\n\n\n<p>You can add your code in<code> main.js<\/code> file. Whatever you want to do in your module. It is same as you write in <code>index.js<\/code> file but methods or function which is overridden, copy the same data in <code>main.js<\/code> file as in <code>index.js<\/code> of override component.<br><br>After that create a twig template for your plugin in following directory <code>&lt;plugin root&gt;\/src\/Resources\/administration\/src\/extension\/sw-order-detail<\/code>.<br>In this case file name is <code>sw-order-detail.html.twig<\/code> <br><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">{% block sw_order_detail_content_tabs %}&lt;br&gt;    {% parent %}&lt;\/code&gt;&lt;br&gt;         &lt;code&gt;{% block  override_content %}&lt;br&gt;               {#  Add your code here #}&lt;br&gt;     {% endblock %}&lt;br&gt;{% endblock %}<\/pre>\n\n\n\n<p>In Twig template, block <code>sw_order_detail_content_tabs<\/code> is overridden . This block contain whole details of order detail page and you can add your custom fields.<br>Block override_content is custom block in here you can add your own code.<br>You can learn more about <a href=\"https:\/\/twig.symfony.com\/doc\/2.x\/templates.html#template-inheritance\">templates inheritance<\/a> to understand &nbsp;how blocks in Twig work.<\/p>\n\n\n\n<p>Now you can run the command <code>.\/psh.phar administration:build<\/code>&nbsp;in your Shopware root directory. <\/p>\n\n\n\n<p>I hope It will help you. Thanks <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will look into modules which can be override and use in our custom module in Shopware 6. I hope you know the directory structure of Shopware 6 plugin, if you don&#8217;t know, see here- https:\/\/docs.shopware.com\/en\/shopware-platform-dev-en\/internals\/directory-structure. Setup : You can create a new plugin for shopware 6. To learn creating a plugin <a href=\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":284,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9568,1],"tags":[],"class_list":["post-200603","post","type-post","status-publish","format-standard","hentry","category-shopware","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to override a Component in Shopware 6 - Webkul Blog<\/title>\n<meta name=\"description\" content=\"Shopware 6 Component overriding in the administration, Twig overriding, Twig JS, Vue JS, ES 2017\" \/>\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\/how-to-override-a-component-in-shopware-6\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to override a Component in Shopware 6 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Shopware 6 Component overriding in the administration, Twig overriding, Twig JS, Vue JS, ES 2017\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-21T05:03:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-26T14:57:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Diwakar Rana\" \/>\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=\"Diwakar Rana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/\"},\"author\":{\"name\":\"Diwakar Rana\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/4b025fe4ecbc5c0378cd13bb70da654f\"},\"headline\":\"How to override a Component in Shopware 6\",\"datePublished\":\"2019-10-21T05:03:40+00:00\",\"dateModified\":\"2019-12-26T14:57:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/\"},\"wordCount\":254,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"articleSection\":[\"Shopware\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/\",\"name\":\"How to override a Component in Shopware 6 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2019-10-21T05:03:40+00:00\",\"dateModified\":\"2019-12-26T14:57:13+00:00\",\"description\":\"Shopware 6 Component overriding in the administration, Twig overriding, Twig JS, Vue JS, ES 2017\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to override a Component in Shopware 6\"}]},{\"@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\/4b025fe4ecbc5c0378cd13bb70da654f\",\"name\":\"Diwakar Rana\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/46482d0264c191ccd0337892016340a80ca4e4987a37f42514a0506aaee7e8dc?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\/46482d0264c191ccd0337892016340a80ca4e4987a37f42514a0506aaee7e8dc?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Diwakar Rana\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/diwakar-rana829\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to override a Component in Shopware 6 - Webkul Blog","description":"Shopware 6 Component overriding in the administration, Twig overriding, Twig JS, Vue JS, ES 2017","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\/how-to-override-a-component-in-shopware-6\/","og_locale":"en_US","og_type":"article","og_title":"How to override a Component in Shopware 6 - Webkul Blog","og_description":"Shopware 6 Component overriding in the administration, Twig overriding, Twig JS, Vue JS, ES 2017","og_url":"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2019-10-21T05:03:40+00:00","article_modified_time":"2019-12-26T14:57:13+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Diwakar Rana","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Diwakar Rana","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/"},"author":{"name":"Diwakar Rana","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/4b025fe4ecbc5c0378cd13bb70da654f"},"headline":"How to override a Component in Shopware 6","datePublished":"2019-10-21T05:03:40+00:00","dateModified":"2019-12-26T14:57:13+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/"},"wordCount":254,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"articleSection":["Shopware"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/","url":"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/","name":"How to override a Component in Shopware 6 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2019-10-21T05:03:40+00:00","dateModified":"2019-12-26T14:57:13+00:00","description":"Shopware 6 Component overriding in the administration, Twig overriding, Twig JS, Vue JS, ES 2017","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-override-a-component-in-shopware-6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to override a Component in Shopware 6"}]},{"@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\/4b025fe4ecbc5c0378cd13bb70da654f","name":"Diwakar Rana","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/46482d0264c191ccd0337892016340a80ca4e4987a37f42514a0506aaee7e8dc?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\/46482d0264c191ccd0337892016340a80ca4e4987a37f42514a0506aaee7e8dc?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Diwakar Rana"},"url":"https:\/\/webkul.com\/blog\/author\/diwakar-rana829\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/200603","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\/284"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=200603"}],"version-history":[{"count":28,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/200603\/revisions"}],"predecessor-version":[{"id":253274,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/200603\/revisions\/253274"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=200603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=200603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=200603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}