How To Create A Simple Plugin In Shopware 5?

How To Create A Simple Plugin In Shopware 5

A Shopware Plugin is a group of files that are needed to create a specific store feature. It is the unit of customization in the Shopware platform. Shopware Plugin can be created to perform multiple functions with supporting logic to influence user experience and storefront appearance. From the perspective of both merchants and extension developers, plugins are the central unit of the Shopware platform.

File structure of plugin:

Step 1: Go to the root directory of your site.

Step 2: Navigate to path custom -> plugins.

Step 3: Create your plugin folder like (NewCustom).

Step 4: Create a PHP file that is required. Like NewCustom.php in this path (Root_Path/custom/plugins/NewCustom/NewCustom.php).

<?php

namespace NewCustom;

use Shopware\Components\Plugin;

class NewCustom extends Plugin
{
          # Your code goes here…
}

Step 5: Create a XML file that is required. Like plugin.xml in this path (Root_Path/custom/plugins/NewCustom/plugin.xml).

<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/
        shopware/5.3/engine/Shopware/Components/Plugin/schema/plugin.xsd">

                 <label lang="en">NewCustom</label>
                 <version>0.0.1</version>
                 <link>http://example.com</link>
                 <author>Name of the author</author>
</plugin>

Step 6: To install and activate the plugin you can do it from the backend or via SSH command:

php bin/console sw:plugin:install NewCustom --activate

For any support on shopware please mail us at manish@bay20.com or Whatsapp Us at +91-8800519180.