Creating a plugin

Throughout the tutorial, you will create a plugin that displays items to promote in your store. Start by creating a basic plugin and deploying it in plentymarkets.

This page covers the following steps:

  • Installing Node.js

  • Installing a plugin generator

  • Creating a new plugin

  • Deploying your plugin in plentymarkets

Installing the plugin generator

You can create new plugins by running a plugin generator. To install the generator, you need an active version of Node.js. To check if you have Node.js installed, open a terminal and run the following command:

$ node --version

If you have Node.js installed, it’ll show the currently active version:

$ node --version
14.15.3

If you don’t have Node.js installed, you can download it from nodejs.org.

After installing Node.js, you’re ready to install the plugin generator. To install the generator, run the following command:

$ npm i -g yo @plentymarkets/generator-plugin

Now you can create your plugin.

Creating the plugin

To create your first plugin, carry out the following steps:

  1. Open the command line.

  2. Navigate to the plugin set folder in your workspace.

  3. Run the following commands:

    $ mkdir TopItems
    $ cd TopItems
    $ yo @plentymarkets/plugin
  4. Follow the prompts of the generator.

    • For each promt, the generator supplies a default value.

    • Except for the plugin type, confirm the default value by pressing enter.

    • For the plugin type select the template option.

The generator creates all the files required for a basic plugin.

Plugin files
workspace/
│
├── 12345/
│	│
│	└── 1/
│       │
│       └── TopItems/
│           │
│           ├── meta/ (1)
│           │
│           ├── resources/ (2)
│           │
│           ├── src/ (3)
│           │
│           ├── .yo-rc.json
│           │
│           ├── config.json (4)
│           │
│           └── plugin.json (5)
│
└── plenty.ignore
1 Stores information about the plugin, for example guides and app images.
2 Provides templates, scripts and other files that are accessed while the plugin is running.
3 Contains the source code of the plugin.
4 Contains options that the user can configure.
5 Contains the details required to run the plugin.

Deploy the plugin in your system to see the result.

Deploying the plugin

In order to deploy your plugin, you first have to install it in your system. You can install a plugin from your local machine by using plentyDevTool.

  1. Open plentyDevTool.

  2. Open the Dashboard.

  3. Click on Detect new local plugins.
    The dashboard displays TopItems.

  4. Click on Install.
    plentyDevTool uploads the TopItems plugin to your system.

Next, you can deploy your plugin.

  1. Open your plentymarkets back end.

  2. Go to Plugins » Plugin overview.

  3. Open the plugin set where you uploaded TopItems.

  4. Toggle TopItems active.

  5. Save the plugin set.
    The plugin set is deployed.

Once the deployment process has finished, you can check the results. For this, open your shop in the browser. Then, append /hello-world to the URL. Your browser now displays the message "Hello World!".

hello world

In the next step, you will modify your plugin to display data from your system.