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’;

Avatar photo
Author

Founder and tech lead at Emizentech, Mr. Vivek has over ten years of experience in developing IT infrastructures and solutions. With his profound knowledge in eCommerce technologies like Shopware, Magento, and Shopify, Mr. Vivek has been assisting SMEs to enterprises across the globe by developing and maintaining their eCommerce applications. Technology innovation and trends insight come easy to Vivek with his thorough knowledge in the eCommerce domain. See him talking about ideas, trends, and technology in this blog. To know more about how Team Vivek can assist you in your eCommerce strategy? Connect team Vivek here.

whatsapp