{"id":12231,"date":"2021-09-11T00:00:27","date_gmt":"2021-09-11T05:30:27","guid":{"rendered":"https:\/\/www.emizentech.com\/blog\/?p=12231"},"modified":"2023-01-30T11:01:43","modified_gmt":"2023-01-30T11:01:43","slug":"add-new-module-to-admin-in-shopware-6","status":"publish","type":"post","link":"https:\/\/multisitelocal.ezxdemo.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>\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>\n<p>Then create a new file \u201cindex.js\u201d consider it to be the main file for your custom module.<\/p>\n<p>Then register your new module and add some settings to your module like this:<\/p>\n<pre>const { Module } = Shopware;\n\nimport '.\/page\/emizentech-module-configuration-main'; \/\/ Added a custom copmonent for configuration\nimport enGB from '.\/snippet\/en-GB'; \/\/ Created a snippet folder and import your snippets here\nimport deDE from '.\/snippet\/de-DE';\n\n\/\/ \u201cModule.register\u201d is used for registration for your custom module \nModule.register('emizentech-module-configuration', {\n    type: 'plugin',\n    title: 'emizentechModuleConfiguration.main.configuration',    description:'emizentechModuleConfiguration.main.configurationDescription',\n    favicon: 'icon-module-products.png',\n\n    snippets: {\n        'en-GB': enGB, \/\/ after import use you snippets here \n        'de-DE': deDE\n    },\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.\n\n    routes: {\n        'main': {\n            component: 'emizentech-module-configuration-main',\n            path: 'main',\n            meta: {\n                parentPath: 'sw.settings.index'\n            }\n        },\n    },\n\/\/ Link your module into settings\n    settingsItem: [{\n            name: 'emizentech-module-configuration',\n            label: 'emizentechModuleConfiguration.main.configuration',\n            to: 'emizentech.module.configuration.main',\n            icon: 'default-package-open',\n            group: 'plugins'\n        }\n    ]\n});\n<\/pre>\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>\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>\n<pre>{\n    \"emizentechModuleConfiguration\": {\n        \"main\": {\n            \"configuration\": \"Emizentech - Configuration\",\n            \"configurationDescription\": \"Configuration of the plugin\"\n        },\n        \"configurationMessages\": {\n            \"title\": \"Success\",\n            \"message\": \"Saved\",\n            \"saveButtonText\": \"Save\",\n            \"errorTitle\": \"Error\",\n            \"errorRequiredValidation\": \"Please fill required fields\",\n            \"cardTitle\": \"Configuration\"    \n        }\n    }\n}\n<\/pre>\n<p>Add this code to in both the files according to the language.<\/p>\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>\n<p>import &#8216;.\/module\/emizentech-module-configuration&#8217;;<\/p>\n\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":{"MSN_Categories":"Uncategorized","MSN_Publish_Option":false,"MSN_Is_Local_News":false,"MSN_Is_AIAC_Included":"Empty","MSN_Location":"[]","MSN_Add_Feature_Img_On_Top_Of_Post":false,"MSN_Has_Custom_Author":false,"MSN_Custom_Author":"","MSN_Has_Custom_Canonical_Url":false,"MSN_Custom_Canonical_Url":"","_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[85],"tags":[84],"class_list":{"0":"post-12231","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-shopware","8":"tag-shopware"},"modified_by":"Marketing EmizenTech","featured_image_src":"https:\/\/multisitelocal.ezxdemo.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:\/\/multisitelocal.ezxdemo.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:\/\/multisitelocal.ezxdemo.com\/blog\/author\/vivek"},"_links":{"self":[{"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/posts\/12231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/comments?post=12231"}],"version-history":[{"count":0,"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/posts\/12231\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/media\/12234"}],"wp:attachment":[{"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/media?parent=12231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/categories?post=12231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multisitelocal.ezxdemo.com\/blog\/wp-json\/wp\/v2\/tags?post=12231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}