The configuration

Each plugin may have a configuration. The entire configuration of your plugin is than managed in the novomind iSHOP backoffice. Each shop administrator that has the necessary permissions can make changes.

In the configureConfigurationTemplate method in the configurer the configuration gets registered.

Supported are the following configuration key types:

  • Simple types: Integer, Double, String, Boolean
  • File: The backoffice manager may upload files
  • Selection: The backoffice manager may select one of different options.

Configuration management

The allow configuration in your plugin, you have to register the configuration. This is done in the ishop section of the plugin manifest:

...
<metadata>
  <ishop:ishop-plugin>
    <ishop:configtemplate>
      <ishop:stringKey key="greeting" default="Hello World">
        <ishop:description locale="en">A greeting that this app displays</ishop:description>
      </ishop:stringKey>
      <ishop:booleanKey key="enableSpecialFeature" default="false">
        <ishop:description locale="en">Enable the special hidden feature of this app!</ishop:description>
        <ishop:description locale="de">Aktiviere das geheime Feature!</ishop:description>
      </ishop:booleanKey>
    </ishop:configtemplate>
    ...

Available key types

String
<ishop:stringKey key="greeting" default="Hello World">
  <ishop:description locale="en">A greeting that this app displays</ishop:description>
</ishop:stringKey>
Boolean
<ishop:booleanKey key="showMessage" default="false">
  <ishop:description locale="en">Whether the greeting should be displayed</ishop:description>
</ishop:booleanKey>
Selectable
<ishop:selectableKey key="messages">
  <ishop:option>Hey there!</ishop:option>
  <ishop:option>Hello stranger!</ishop:option>
  <ishop:description locale="en">The greeting to show</ishop:description>
</ishop:selectableKey>
File
<ishop:fileKey key="picture" maxFileSize="1000" fileExtensions="jpg,png">
  <ishop:description locale="en">A picture to show next to the message</ishop:description>
</ishop:fileKey>
Integer
<ishop:integerKey key="numberOfMessages" default="3">
  <ishop:description locale="en">How many messages should be shown</ishop:description>
</ishop:integerKey>
Double
<ishop:doubleKey key="messageFontSize" default="2.5">
  <ishop:description locale="en">The font size of the message in em</ishop:description>
</ishop:doubleKey>

Manage the configuration

Shop Managers can manage the configuration of all plugins in the backoffice. They need the administrative permission "apps" to do that.

Access the configuration

PluginConfigurationService

The PluginConfigurationService lets you access the configuration from java classes. It is a service managed by spring so it has to be injected into your class. It requires the current shopcontext which is usually available through the ApiShopContextFactory, that is also managed by spring.

pluginConfigurationService.getStringValue(apiShopContext, "twitter.apikey").orElse("MY-API-KEY");
pluginConfigurationService.getBooleanValue(apiShopContext, "twitter.debug").orElse(Boolean.FALSE);
pluginConfigurationService.getIntegerValue(apiShopContext, "twitter.history").orElse(10);

ConfigTag

To access the configuration directly from the frontend, you can use the configTag.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.novomind.com/ishop/api" prefix="api" %>

<api:config key="twitter.apikey" var="apikey" />
<api:config key="twitter.debug" var="debug" />
<api:config key="twitter.history" var="history" />
<c:if test="debug">
  Using API-KEY: <c:out value="${apikey}" />
  Saving the last <c:out value="${history}" />  actions.
</c:if>