Marketplace Promotions & Discounts feature integration

Edit on GitHub

This document describes how to integrate the Marketplace Promotions & Discounts feature into a Spryker project.

Install feature core

Follow the steps below to install the Marketplace Promotions & Discounts feature core.

Prerequisites

To start feature integration, integrate the required features:

NAME VERSION INTEGRATION GUIDE
Spryker Core 202204.0 Spryker Core feature integration
Marketplace Order Management 202204.0 Marketplace Order Management feature integration
Promotions & Discounts 202204.0 Promotions & Discounts feature integration

1) Install the required modules using Composer

Install the required modules:

composer require spryker-feature/marketplace-promotions-discounts:"202204.0" --update-with-dependencies
Verification

Make sure that the following modules were installed:

MODULE EXPECTED DIRECTORY
DiscountMerchantSalesOrder vendor/spryker/discount-merchant-sales-order
DiscountMerchantSalesOrderGui vendor/spryker/discount-merchant-sales-order-gui

2) Set up configuration

Add the following configuration:

CONFIGURATION SPECIFICATION NAMESPACE
MerchantSalesOrderMerchantUserGuiConfig::getMerchantSalesOrderDetailExternalBlocksUrls() Introduces list of urls of order detail page configuration. src/Pyz/Zed/MerchantSalesOrderMerchantUserGui/MerchantSalesOrderMerchantUserGuiConfig.php

src/Pyz/Zed/MerchantSalesOrderMerchantUserGui/MerchantSalesOrderMerchantUserGuiConfig.php

<?php

namespace Pyz\Zed\MerchantSalesOrderMerchantUserGui;

use Spryker\Zed\MerchantSalesOrderMerchantUserGui\MerchantSalesOrderMerchantUserGuiConfig as SprykerMerchantSalesOrderMerchantUserGuiConfig;

class MerchantSalesOrderMerchantUserGuiConfig extends SprykerMerchantSalesOrderMerchantUserGuiConfig
{
    /**
     * @return string[]
     */
    public function getMerchantSalesOrderDetailExternalBlocksUrls(): array
    {
        return [
            'discount' => '/discount-merchant-sales-order-gui/merchant-sales-order/list',
        ];
    }
}

3) Set up the transfer objects

Generate transfer changes:

console transfer:generate
Verification

Make sure that the following changes were applied in transfer objects:

TRANSFER TYPE EVENT PATH
CalculatedDiscount.fkSalesOrderItem property created src/Generated/Shared/Transfer/CalculatedDiscountTransfer

4) Add translations

Generate a new translation cache for Zed:

console translator:generate-cache

5) Set up behavior

Enable the following behaviors by registering the plugins:

PLUGIN DESCRIPTION PREREQUISITES NAMESPACE
DiscountMerchantOrderFilterPlugin Removes none merchant-related discounts from merchant orders. Spryker\Zed\DiscountMerchantSalesOrder\Communication\Plugin

src/Pyz/Zed/MerchantSalesOrder/MerchantSalesOrderDependencyProvider.php

<?php

namespace Pyz\Zed\MerchantSalesOrder;

use Spryker\Zed\DiscountMerchantSalesOrder\Communication\Plugin\DiscountMerchantOrderFilterPlugin;
use Spryker\Zed\MerchantSalesOrder\MerchantSalesOrderDependencyProvider as SprykerMerchantSalesOrderDependencyProvider;

class MerchantSalesOrderDependencyProvider extends SprykerMerchantSalesOrderDependencyProvider
{
    /**
     * @return \Spryker\Zed\MerchantSalesOrderExtension\Dependency\Plugin\MerchantOrderFilterPluginInterface[]
     */
    protected function getMerchantOrderFilterPlugins(): array
    {
        return [
            new DiscountMerchantOrderFilterPlugin(),
        ];
    }
}

Verification

Make sure that correct discounts are applied to the merchant orders when viewing them in the Back Office.