For adding a module in shopware first create a basic plugin
Then, create a new directory located at “Emizentech/src/Resources/app/administration/src/module/emizentech-module-configuration” so you can store your own modules files in there.
Then create a new file “index.js” consider it to be the main file for your custom module.
Then register your new module and add some settings to your module like this:
const { Module } = Shopware; import './page/emizentech-module-configuration-main'; // Added a custom copmonent for configuration import enGB from './snippet/en-GB'; // Created a snippet folder and import your snippets here import deDE from './snippet/de-DE'; // “Module.register” is used for registration for your custom module Module.register('emizentech-module-configuration', { type: 'plugin', title: 'emizentechModuleConfiguration.main.configuration', description:'emizentechModuleConfiguration.main.configurationDescription', favicon: 'icon-module-products.png', snippets: { 'en-GB': enGB, // after import use you snippets here 'de-DE': deDE }, // 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. routes: { 'main': { component: 'emizentech-module-configuration-main', path: 'main', meta: { parentPath: 'sw.settings.index' } }, }, // Link your module into settings settingsItem: [{ name: 'emizentech-module-configuration', label: 'emizentechModuleConfiguration.main.configuration', to: 'emizentech.module.configuration.main', icon: 'default-package-open', group: 'plugins' } ] });
Now,for importing your snippets in your module create a folder named “snippet” at location “Emizentech/src/Resources/app/administration/src/module/emizentech-module-configuration”
And now create two files for snippet in snippet folder “de-DE.json” & “en-GB.json” and add your snippets in there like this:-
{ "emizentechModuleConfiguration": { "main": { "configuration": "Emizentech - Configuration", "configurationDescription": "Configuration of the plugin" }, "configurationMessages": { "title": "Success", "message": "Saved", "saveButtonText": "Save", "errorTitle": "Error", "errorRequiredValidation": "Please fill required fields", "cardTitle": "Configuration" } } }
Add this code to in both the files according to the language.
Custom module directory isn’t known to Shopware 6 yet. The entry point of your plugin is the main.js file. That’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:
import ‘./module/emizentech-module-configuration’;