{"id":12231,"date":"2021-09-11T00:00:27","date_gmt":"2021-09-11T05:30:27","guid":{"rendered":"https:\/\/emizentech.com\/blog\/?p=12231"},"modified":"2024-12-31T06:36:28","modified_gmt":"2024-12-31T06:36:28","slug":"add-new-module-to-admin-in-shopware-6","status":"publish","type":"post","link":"https:\/\/emizentech.com\/blog\/add-new-module-to-admin-in-shopware-6.html","title":{"rendered":"How To Add New Module To Admin In Shopware 6"},"content":{"rendered":"<p>For adding a module in shopware first create a basic plugin<\/p>\r\n<p>Then, create a new directory located at \u201cEmizentech\/src\/Resources\/app\/administration\/src\/module\/emizentech-module-configuration\u201d so you can store your own modules files in there.<\/p>\r\n<p>Then create a new file \u201cindex.js\u201d consider it to be the main file for your custom module.<\/p>\r\n<p>Then register your new module and add some settings to your module like this:<\/p>\r\n<pre>const { Module } = Shopware;\r\n\r\nimport '.\/page\/emizentech-module-configuration-main'; \/\/ Added a custom copmonent for configuration\r\nimport enGB from '.\/snippet\/en-GB'; \/\/ Created a snippet folder and import your snippets here\r\nimport deDE from '.\/snippet\/de-DE';\r\n\r\n\/\/ \u201cModule.register\u201d is used for registration for your custom module \r\nModule.register('emizentech-module-configuration', {\r\n    type: 'plugin',\r\n    title: 'emizentechModuleConfiguration.main.configuration',    description:'emizentechModuleConfiguration.main.configurationDescription',\r\n    favicon: 'icon-module-products.png',\r\n\r\n    snippets: {\r\n        'en-GB': enGB, \/\/ after import use you snippets here \r\n        'de-DE': deDE\r\n    },\r\n\/\/ routes which your module is going to use, such as e.g.  emizentech-module-configuration-main for the main setting of your module, emizentech-module-detail for the detail page and emizentech-module-create for creating a new entry.\r\n\r\n    routes: {\r\n        'main': {\r\n            component: 'emizentech-module-configuration-main',\r\n            path: 'main',\r\n            meta: {\r\n                parentPath: 'sw.settings.index'\r\n            }\r\n        },\r\n    },\r\n\/\/ Link your module into settings\r\n    settingsItem: [{\r\n            name: 'emizentech-module-configuration',\r\n            label: 'emizentechModuleConfiguration.main.configuration',\r\n            to: 'emizentech.module.configuration.main',\r\n            icon: 'default-package-open',\r\n            group: 'plugins'\r\n        }\r\n    ]\r\n});\r\n<\/pre>\r\n<p>Now,for importing your snippets in your module create a folder named \u201csnippet\u201d at location \u201cEmizentech\/src\/Resources\/app\/administration\/src\/module\/emizentech-module-configuration\u201d<\/p>\r\n<p>And now create two files for snippet in snippet folder \u201cde-DE.json\u201d &amp; \u201cen-GB.json\u201d and add your snippets in there like this:-<\/p>\r\n<pre>{\r\n    \"emizentechModuleConfiguration\": {\r\n        \"main\": {\r\n            \"configuration\": \"Emizentech - Configuration\",\r\n            \"configurationDescription\": \"Configuration of the plugin\"\r\n        },\r\n        \"configurationMessages\": {\r\n            \"title\": \"Success\",\r\n            \"message\": \"Saved\",\r\n            \"saveButtonText\": \"Save\",\r\n            \"errorTitle\": \"Error\",\r\n            \"errorRequiredValidation\": \"Please fill required fields\",\r\n            \"cardTitle\": \"Configuration\"    \r\n        }\r\n    }\r\n}\r\n<\/pre>\r\n<p>Add this code to in both the files according to the language.<\/p>\r\n<p>Custom module directory isn&#8217;t known to Shopware 6 yet. The entry point of your plugin is the main.js file. That&#8217;s the file you need to change now, so that it loads your new module. For this, simply add the following line to your main.js file:<\/p>\r\n<p>import &#8216;.\/module\/emizentech-module-configuration&#8217;;<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>For adding a module in shopware first create a basic plugin Then, create a new directory located at \u201cEmizentech\/src\/Resources\/app\/administration\/src\/module\/emizentech-module-configuration\u201d so you can store your own modules files in there. Then create a new file \u201cindex.js\u201d consider it to be the main file for your custom module. Then register your new module and add some settings<\/p>\n","protected":false},"author":36,"featured_media":12234,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[85],"tags":[84],"class_list":["post-12231","post","type-post","status-publish","format-standard","has-post-thumbnail","category-shopware","tag-shopware"],"jetpack_featured_media_url":"https:\/\/emizentech.com\/blog\/wp-content\/uploads\/sites\/2\/2021\/09\/Add-New-Module-To-Admin-In-Shopware-6-1-1.jpg","featured_image_src":"https:\/\/emizentech.com\/blog\/wp-content\/uploads\/sites\/2\/2021\/09\/Add-New-Module-To-Admin-In-Shopware-6-1-1.jpg","featured_image_src_square":"https:\/\/emizentech.com\/blog\/wp-content\/uploads\/sites\/2\/2021\/09\/Add-New-Module-To-Admin-In-Shopware-6-1-1.jpg","author_info":{"display_name":"Vivek Khatri","author_link":"https:\/\/emizentech.com\/blog\/author\/vivek"},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/posts\/12231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/comments?post=12231"}],"version-history":[{"count":1,"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/posts\/12231\/revisions"}],"predecessor-version":[{"id":44443,"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/posts\/12231\/revisions\/44443"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/media\/12234"}],"wp:attachment":[{"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/media?parent=12231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/categories?post=12231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emizentech.com\/blog\/wp-json\/wp\/v2\/tags?post=12231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}