{"id":312450,"date":"2021-11-19T13:22:33","date_gmt":"2021-11-19T13:22:33","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=312450"},"modified":"2021-11-19T13:22:36","modified_gmt":"2021-11-19T13:22:36","slug":"implementing-a-custom-component-into-the-default-config-form","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/","title":{"rendered":"Implementing a custom component into the default Config form"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>In this post, we will discuss how to implement a custom component in the default plugin config.xml file. It is a very interesting topic when we want to add some custom components in config.xml file. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Overview <\/h2>\n\n\n\n<p>We can achieve this by creating a new component in the administration\/src folder, so let&#8217;s start to implement a custom component in the default plugin config.xml<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding a custom component in default config.xml <\/h2>\n\n\n\n<p>We add our own component in config.xml file which will be created.<\/p>\n\n\n\n<p>add plugin configuration. <a href=\"https:\/\/developer.shopware.com\/docs\/guides\/plugins\/plugins\/plugin-fundamentals\/add-plugin-configuration\">docs<\/a><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;\n        xsi:noNamespaceSchemaLocation=&quot;https:\/\/raw.githubusercontent.com\/shopware\/platform\/master\/src\/Core\/System\/SystemConfig\/Schema\/config.xsd&quot;&gt;\n\n    &lt;card&gt;\n        &lt;title&gt;Plugin Configuration&lt;\/title&gt;\n        &lt;input-field&gt;\n            &lt;name&gt;username&lt;\/name&gt;\n            &lt;label&gt;Username&lt;\/label&gt;\n        &lt;\/input-field&gt;\n        &lt;input-field type=&quot;password&quot;&gt;\n            &lt;name&gt;password&lt;\/name&gt;\n            &lt;label&gt;Password&lt;\/label&gt;\n        &lt;\/input-field&gt;\n        &lt;component name=&quot;wk-api-test-button&quot;&gt;\n            &lt;name&gt;apiTest&lt;\/name&gt;\n            &lt;label&gt;API Validation&lt;\/label&gt;\n        &lt;\/component&gt;\n    &lt;\/card&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p>In the above code, we have added a component with the name &#8220;wk-api-test-button&#8221;, now we are going to create &#8220;wk-api-test-button&#8221; componet.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding custom component for config<\/h2>\n\n\n\n<p>Now we add our own component, so we create component\/wk-api-test-button in  administration\/src folder and also create js and HTML files. first of all, we created an HTML file please have a look below in the code section.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;div&gt;\n    &lt;sw-button-process\n        :isLoading=&quot;isLoading&quot;\n        :processSuccess=&quot;isSaveSuccessful&quot;\n        @process-finish=&quot;saveFinish&quot;\n        @click=&quot;check&quot;\n    &gt;{{ $tc(&#039;wk-api-test-button.button&#039;) }}&lt;\/sw-button-process&gt;\n&lt;\/div&gt;<\/pre>\n\n\n\n<p>In the above code, we add a button for API test which is used in system config.<\/p>\n\n\n\n<p>Now create an index.js file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">const { Component, Mixin } = Shopware;\nimport template from &#039;.\/wk-api-test-button.html.twig&#039;;\n\nComponent.register(&#039;wk-api-test-button&#039;, {\n    template,\n\n    props: &#091;&#039;label&#039;],\n    inject: &#091;&#039;wkApiTest&#039;],\n\n    mixins: &#091;\n        Mixin.getByName(&#039;notification&#039;)\n    ],\n\n    data() {\n        return {\n            isLoading: false,\n            isSaveSuccessful: false,\n        };\n    },\n\n    computed: {\n        pluginConfig() {\n            let $parent = this.$parent;\n\n            while ($parent.actualConfigData === undefined) {\n                $parent = $parent.$parent;\n            }\n\n            return $parent.actualConfigData.null;\n        }\n    },\n\n    methods: {\n        saveFinish() {\n            this.isSaveSuccessful = false;\n        },\n\n        check() {\n            this.isLoading = true;\n            this.wkApiTest.check(this.pluginConfig).then((res) =&gt; {\n                if (res.success) {\n                    this.isSaveSuccessful = true;\n                    this.createNotificationSuccess({\n                        title: this.$tc(&#039;wk-api-test-button.title&#039;),\n                        message: this.$tc(&#039;wk-api-test-button.success&#039;)\n                    });\n                } else {\n                    this.createNotificationError({\n                        title: this.$tc(&#039;wk-api-test-button.title&#039;),\n                        message: this.$tc(&#039;wk-api-test-button.error&#039;)\n                    });\n                }\n\n                this.isLoading = false;\n            });\n        }\n    }\n})<\/pre>\n\n\n\n<p>In the above code, we created a check method for the test API button and call the wkApiTest service. In API service we can create the HTTP request for our logic and return the response. <\/p>\n\n\n\n<p>Thanks for reading, so I hope it will help you. Happy coding \ud83d\ude42<\/p>\n\n\n\n<p><a href=\"https:\/\/webkul.com\/blog\/shopware-multi-seller-marketplace\/\" target=\"_blank\" rel=\"noreferrer noopener\">Multi-Seller Marketplace Plugin<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In this post, we will discuss how to implement a custom component in the default plugin config.xml file. It is a very interesting topic when we want to add some custom components in config.xml file. Overview We can achieve this by creating a new component in the administration\/src folder, so let&#8217;s start to implement <a href=\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":325,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-312450","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>custom component in default config<\/title>\n<meta name=\"description\" content=\"implement a custom component in the default plugin config| how to add custom component in the system config form\" \/>\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\/implementing-a-custom-component-into-the-default-config-form\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"custom component in default config\" \/>\n<meta property=\"og:description\" content=\"implement a custom component in the default plugin config| how to add custom component in the system config form\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/\" \/>\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=\"2021-11-19T13:22:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-19T13:22:36+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=\"Prince Gupta\" \/>\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=\"Prince Gupta\" \/>\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\/implementing-a-custom-component-into-the-default-config-form\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/\"},\"author\":{\"name\":\"Prince Gupta\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/669b7c5067f73a7ae2204ff4aca829fd\"},\"headline\":\"Implementing a custom component into the default Config form\",\"datePublished\":\"2021-11-19T13:22:33+00:00\",\"dateModified\":\"2021-11-19T13:22:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/\"},\"wordCount\":239,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/\",\"url\":\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/\",\"name\":\"custom component in default config\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2021-11-19T13:22:33+00:00\",\"dateModified\":\"2021-11-19T13:22:36+00:00\",\"description\":\"implement a custom component in the default plugin config| how to add custom component in the system config form\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Implementing a custom component into the default Config form\"}]},{\"@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\/669b7c5067f73a7ae2204ff4aca829fd\",\"name\":\"Prince Gupta\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dd55a986709c72a714a8135a38f3b2cba1009ea371caec823a8547b2e01df18d?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\/dd55a986709c72a714a8135a38f3b2cba1009ea371caec823a8547b2e01df18d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Prince Gupta\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/princegupta-wp031\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"custom component in default config","description":"implement a custom component in the default plugin config| how to add custom component in the system config form","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\/implementing-a-custom-component-into-the-default-config-form\/","og_locale":"en_US","og_type":"article","og_title":"custom component in default config","og_description":"implement a custom component in the default plugin config| how to add custom component in the system config form","og_url":"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2021-11-19T13:22:33+00:00","article_modified_time":"2021-11-19T13:22:36+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":"Prince Gupta","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Prince Gupta","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/"},"author":{"name":"Prince Gupta","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/669b7c5067f73a7ae2204ff4aca829fd"},"headline":"Implementing a custom component into the default Config form","datePublished":"2021-11-19T13:22:33+00:00","dateModified":"2021-11-19T13:22:36+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/"},"wordCount":239,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/","url":"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/","name":"custom component in default config","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2021-11-19T13:22:33+00:00","dateModified":"2021-11-19T13:22:36+00:00","description":"implement a custom component in the default plugin config| how to add custom component in the system config form","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/implementing-a-custom-component-into-the-default-config-form\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Implementing a custom component into the default Config form"}]},{"@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\/669b7c5067f73a7ae2204ff4aca829fd","name":"Prince Gupta","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/dd55a986709c72a714a8135a38f3b2cba1009ea371caec823a8547b2e01df18d?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\/dd55a986709c72a714a8135a38f3b2cba1009ea371caec823a8547b2e01df18d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Prince Gupta"},"url":"https:\/\/webkul.com\/blog\/author\/princegupta-wp031\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/312450","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\/325"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=312450"}],"version-history":[{"count":1,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/312450\/revisions"}],"predecessor-version":[{"id":312463,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/312450\/revisions\/312463"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=312450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=312450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=312450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}