Customers also bought for Shopware 6

Integration guide for the app DmfCabRecommendations, version 1.0.0

This server runs the Customers also bought app. Once installed, the app gives every product a cross-selling list with the products customers bought together with it in the last 180 days. The lists are recalculated automatically every day and appear as a regular cross-selling tab on the product page.

1. Requirements

2. Installation

Download the app package

Download DmfCabRecommendations.zip

The ZIP contains the folder DmfCabRecommendations with the files manifest.xml and Resources/config/config.xml. The URLs of this server are already filled in. Only the app secret is missing: before installing, replace YOUR-APP-SECRET in manifest.xml with the app secret.

manifest.xml for product-recommendation-app.dmf-kunden.com
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/App/Manifest/Schema/manifest-2.0.xsd">
    <meta>
        <name>DmfCabRecommendations</name>
        <label>Customers also bought</label>
        <label lang="de-DE">Kunden kauften auch</label>
        <description>Creates "customers also bought" cross-selling lists per product based on the orders of the last 180 days.</description>
        <description lang="de-DE">Erstellt pro Produkt eine Cross-Selling-Liste „Kunden kauften auch“ auf Basis der Bestellungen der letzten 180 Tage.</description>
        <author>digital.manufaktur GmbH</author>
        <copyright>(c) digital.manufaktur GmbH</copyright>
        <version>1.0.0</version>
        <license>proprietary</license>
    </meta>

    <setup>
        <!-- Replace product-recommendation-app.dmf-kunden.com with the public URL of the app server (APP_URL). -->
        <registrationUrl>product-recommendation-app.dmf-kunden.com/app/register</registrationUrl>
        <!-- Only for apps not distributed via the Shopware Store. Must match APP_SECRET. -->
        <secret>YOUR-APP-SECRET</secret>
    </setup>

    <admin>
        <action-button action="dmfCabRecalculate" entity="product" view="list" url="product-recommendation-app.dmf-kunden.com/app/action/recalculate">
            <label>Recalculate "Customers also bought"</label>
            <label lang="de-DE">„Kunden kauften auch“ neu berechnen</label>
        </action-button>
        <action-button action="dmfCabEnable" entity="product" view="list" url="product-recommendation-app.dmf-kunden.com/app/action/enable">
            <label>Enable "Customers also bought"</label>
            <label lang="de-DE">„Kunden kauften auch“ aktivieren</label>
        </action-button>
        <action-button action="dmfCabDisable" entity="product" view="list" url="product-recommendation-app.dmf-kunden.com/app/action/disable">
            <label>Disable "Customers also bought"</label>
            <label lang="de-DE">„Kunden kauften auch“ deaktivieren</label>
        </action-button>
        <action-button action="dmfCabRemove" entity="product" view="list" url="product-recommendation-app.dmf-kunden.com/app/action/remove">
            <label>Remove "Customers also bought"</label>
            <label lang="de-DE">„Kunden kauften auch“ entfernen</label>
        </action-button>
    </admin>

    <permissions>
        <read>order</read>
        <read>order_line_item</read>
        <read>state_machine_state</read>
        <read>product</read>
        <!-- Shopware requires update on the product to delete one of its cross-sellings. -->
        <update>product</update>
        <read>system_config</read>
        <read>language</read>
        <read>locale</read>
        <read>product_cross_selling</read>
        <create>product_cross_selling</create>
        <update>product_cross_selling</update>
        <delete>product_cross_selling</delete>
        <read>product_cross_selling_translation</read>
        <create>product_cross_selling_translation</create>
        <update>product_cross_selling_translation</update>
        <delete>product_cross_selling_translation</delete>
        <read>product_cross_selling_assigned_products</read>
        <create>product_cross_selling_assigned_products</create>
        <update>product_cross_selling_assigned_products</update>
        <delete>product_cross_selling_assigned_products</delete>
    </permissions>

    <webhooks>
        <webhook name="appActivated" url="product-recommendation-app.dmf-kunden.com/app/webhook/lifecycle" event="app.activated"/>
        <webhook name="appDeactivated" url="product-recommendation-app.dmf-kunden.com/app/webhook/lifecycle" event="app.deactivated"/>
        <webhook name="appDeleted" url="product-recommendation-app.dmf-kunden.com/app/webhook/lifecycle" event="app.deleted"/>
    </webhooks>
</manifest>

Keep the app secret confidential. Anyone who knows it can register a shop with this server.

Option A: Installation via the command line

  1. Extract the ZIP into the folder custom/apps of your Shopware installation:
    unzip DmfCabRecommendations.zip -d custom/apps
  2. In custom/apps/DmfCabRecommendations/manifest.xml, replace YOUR-APP-SECRET with the app secret.
  3. Install and activate the app. --force grants the requested permissions without an interactive prompt:
    bin/console app:install --activate --force DmfCabRecommendations

Option B: Installation in the Administration

  1. Extract the ZIP, replace YOUR-APP-SECRET in DmfCabRecommendations/manifest.xml with the app secret and create a ZIP again. It must contain the folder DmfCabRecommendations, not just its contents:
    zip -r DmfCabRecommendations.zip DmfCabRecommendations
  2. In the Administration, open Extensions › My extensions and choose Upload extension.
  3. Install the uploaded app, accept the requested permissions and activate it.

During the installation, the shop registers with this server and grants it access to its Admin API. As soon as the app is activated, the first calculation is started. Depending on the number of orders, it takes a few seconds to a few minutes.

3. Check the result

  1. Open a product that was ordered together with other products in the last 180 days, in Catalogues › Products.
  2. On the Cross Selling tab, you find a list of the type Manual assignment titled “Kunden kauften auch” / “Customers also bought” (depending on the language).
  3. In the storefront, the list is shown as a tab below the product details. Variants show the list of their main product.

Products are only recommended if they were bought together in at least two orders (configurable), so in shops with few orders not every product gets a list.

4. Configuration

Open Extensions › My extensions, then choose Configure in the app's menu. Changes take effect with the next calculation.

SettingDefaultDescription
Considered period (days)180Orders placed within this number of days are evaluated. Cancelled orders are ignored.
Maximum number of products per list12
Minimum number of joint orders2A product is only recommended if it was bought together with the current product in at least this many orders.
Ignore orders with more than this number of different products50Very large orders (e.g. B2B bulk orders) say little about which products belong together. 0 disables the limit.
Titles per language (optional)–One line per language in the form "locale=title", e.g. "en-GB=Frequently bought together". A language code ("en=…") applies to all its locales. Leave empty to use the built-in translations ("Kunden kauften auch", "Customers also bought", …).
Position among the product's cross-sellings1

Titles per language

The title of the list is written in every language of the shop. Built-in translations exist for German, English, French, Dutch, Italian, Spanish, Portuguese, Polish, Czech, Slovak, Danish, Swedish, Norwegian, Finnish, Hungarian, Romanian and Turkish. To change a title, add one line per language to Titles per language:

de-DE=Wird oft zusammen gekauft
en=Frequently bought together

A language code (en) applies to all its locales, a locale (de-CH) only to itself. Languages without a title show the title of the shop's default language.

5. Actions in the product overview

Open Catalogues › Products and click the ⋯ button in the top bar of the product overview. The app adds these actions; each one only takes a moment, the work is done in the background.

ActionEffect
Recalculate "Customers also bought"Recalculates the lists right away, e.g. after changing the configuration.
Enable "Customers also bought"Shows the lists again after disabling them, or creates them again after removing them. Starts a recalculation.
Disable "Customers also bought"Hides all lists in the storefront. They keep being updated in the background.
Remove "Customers also bought"Deletes all lists of the app after a confirmation. No new lists are created until you enable them again.

The lists are recalculated every day, also while they are disabled. After removing them, nothing is calculated until they are enabled again.

6. How the lists are calculated

7. Permissions

The app requests the following permissions. It does not change products, orders or customer data.

EntityAccess
orderread
order_line_itemread
state_machine_stateread
productread, update
system_configread
languageread
localeread
product_cross_sellingread, create, update, delete
product_cross_selling_translationread, create, update, delete
product_cross_selling_assigned_productsread, create, update, delete

Shopware requires the update permission on product to delete a cross-selling of a product.

8. Uninstalling

When the app is uninstalled, the shop is removed from this server and no further calculations are made. The cross-sellings created so far remain in the shop as regular cross-sellings. To delete them, choose Remove in the product overview first and uninstall the app once the lists are gone.

9. Troubleshooting

SymptomCause and solution
The installation fails with “App system request target is not allowed”. Shopware only allows app servers at public HTTPS addresses. Make sure the URLs in manifest.xml point to product-recommendation-app.dmf-kunden.com.
The installation fails during the registration. Check that <secret> contains the correct app secret and that the shop can reach product-recommendation-app.dmf-kunden.com/app/register.
No cross-sellings appear. Check that there are orders in the configured period in which products were bought together often enough (see Minimum number of joint orders). Make sure this server can reach the shop URL.
After an app update, calculations fail with a missing permission. New versions may request additional permissions. Update the app in the Administration and accept the permissions, or run bin/console app:refresh --force.