Marketplace Order Management feature integration

Edit on GitHub

This document describes how to integrate the Marketplace Order Management feature into a Spryker project.

Install feature core

Follow the steps below to install the Marketplace Order Management feature core.

Prerequisites

To start feature integration, integrate the required features:

NAME VERSION INTEGRATION GUIDE
Spryker Core 202108.0 Spryker Core feature integration
Order Management 202108.0 Order Management feature integration
State Machine 202108.0 State Machine feature integration
Marketplace Merchant 202108.0 Marketplace Merchant feature integration
Marketplace Shipment 202108.0 Marketplace Shipment feature integration

1) Install required modules using Сomposer

Install the required modules:

composer require spryker-feature/marketplace-order-management:"202108.0" --update-with-dependencies
Verification

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
MerchantOms vendor/spryker/merchant-oms
MerchantOmsDataImport vendor/spryker/merchant-oms-data-import
MerchantOmsGui vendor/spryker/merchant-oms-gui
MerchantSalesOrder vendor/spryker/merchant-sales-order
MerchantSalesOrderMerchantUserGui vendor/spryker/merchant-sales-order-merchant-user-gui
MerchantSalesOrderDataExport vendor/spryker/merchant-sales-order-data-export
ProductOfferSales vendor/spryker/product-offer-sales

2) Set up configuration

Add the following configuration:

CONFIGURATION SPECIFICATION NAMESPACE
MainMerchantStateMachine Introduce MainMerchantStateMachine configuration. config/Zed/StateMachine/Merchant/MainMerchantStateMachine.xml
MerchantDefaultStateMachine Introduce MerchantDefaultStateMachine configuration. config/Zed/StateMachine/Merchant/MerchantDefaultStateMachine.xml
MarketplacePayment Introduce MarketplacePayment order management system. config/Zed/oms/MarketplacePayment01.xml
Navigation Introduce navigation configuration. config/Zed/navigation.xml
config/Zed/StateMachine/Merchant/MainMerchantStateMachine.xml
<?xml version="1.0"?>
<statemachine
    xmlns="spryker:state-machine-01"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="spryker:state-machine-01 http://static.spryker.com/state-machine-01.xsd"
>
    <process name="MainMerchantStateMachine" main="true">

        <states>
            <state name="created"/>
            <state name="new"/>
            <state name="canceled"/>
            <state name="left the merchant location"/>
            <state name="arrived at distribution center"/>
            <state name="shipped"/>
            <state name="delivered"/>
            <state name="closed"/>
        </states>

        <transitions>
            <transition happy="true">
                <source>created</source>
                <target>new</target>
                <event>initiate</event>
            </transition>

            <transition>
                <source>new</source>
                <target>closed</target>
                <event>close</event>
            </transition>

            <transition>
                <source>new</source>
                <target>canceled</target>
                <event>cancel</event>
            </transition>

            <transition>
                <source>canceled</source>
                <target>closed</target>
                <event>close</event>
            </transition>

            <transition happy="true">
                <source>new</source>
                <target>left the merchant location</target>
                <event>send to distribution</event>
            </transition>

            <transition happy="true">
                <source>left the merchant location</source>
                <target>arrived at distribution center</target>
                <event>confirm at center</event>
            </transition>

            <transition happy="true">
                <source>arrived at distribution center</source>
                <target>shipped</target>
                <event>ship</event>
            </transition>

            <transition happy="true">
                <source>shipped</source>
                <target>delivered</target>
                <event>deliver</event>
            </transition>

            <transition happy="true">
                <source>delivered</source>
                <target>closed</target>
                <event>close</event>
            </transition>
        </transitions>

        <events>
            <event name="initiate" onEnter="true"/>
            <event name="send to distribution" manual="true"/>
            <event name="confirm at center" manual="true"/>
            <event name="ship" manual="true" command="MarketplaceOrder/ShipOrderItem"/>
            <event name="deliver" manual="true" command="MarketplaceOrder/DeliverOrderItem"/>
            <event name="close"/>
            <event name="cancel" manual="true" command="MarketplaceOrder/CancelOrderItem"/>
        </events>

    </process>

</statemachine>

config/Zed/StateMachine/Merchant/MerchantDefaultStateMachine.xml
<?xml version="1.0"?>
<statemachine
    xmlns="spryker:state-machine-01"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="spryker:state-machine-01 http://static.spryker.com/state-machine-01.xsd"
>

    <process name="MerchantDefaultStateMachine" main="true">

        <states>
            <state name="created"/>
            <state name="new"/>
            <state name="canceled by merchant"/>
            <state name="shipped"/>
            <state name="delivered"/>
            <state name="closed"/>
        </states>

        <transitions>
            <transition happy="true">
                <source>created</source>
                <target>new</target>
                <event>initiate</event>
            </transition>

            <transition happy="true">
                <source>new</source>
                <target>shipped</target>
                <event>ship</event>
            </transition>

            <transition>
                <source>new</source>
                <target>closed</target>
                <event>close</event>
            </transition>

            <transition>
                <source>new</source>
                <target>canceled by merchant</target>
                <event>cancel by merchant</event>
            </transition>

            <transition>
                <source>canceled by merchant</source>
                <target>closed</target>
                <event>close</event>
            </transition>

            <transition happy="true">
                <source>shipped</source>
                <target>delivered</target>
                <event>deliver</event>
            </transition>

            <transition happy="true">
                <source>delivered</source>
                <target>closed</target>
                <event>close</event>
            </transition>
        </transitions>

        <events>
            <event name="initiate" onEnter="true"/>
            <event name="ship" manual="true" command="MarketplaceOrder/ShipOrderItem"/>
            <event name="deliver" manual="true" command="MarketplaceOrder/DeliverOrderItem"/>
            <event name="close"/>
            <event name="cancel by merchant" manual="true" command="MarketplaceOrder/CancelOrderItem"/>
        </events>

    </process>

</statemachine>

config/Zed/oms/MarketplacePayment01.xml
<?xml version="1.0"?>
<statemachine
    xmlns="spryker:oms-01"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="spryker:oms-01 http://static.spryker.com/oms-01.xsd"
>

    <process name="MarketplacePayment01" main="true">
        <states>
            <state name="new" reserved="true" display="oms.state.new"/>
            <state name="paid" reserved="true" display="oms.state.paid"/>
            <state name="canceled" display="oms.state.canceled"/>
            <state name="refunded" display="oms.state.refunded"/>
            <state name="merchant split pending" reserved="true" display="oms.state.merchant-split-pending"/>
            <state name="sent to merchant" reserved="true" display="oms.state.sent-to-merchant"/>
            <state name="shipped by merchant" reserved="true" display="oms.state.shipped-by-merchant"/>
            <state name="delivered" reserved="true" display="oms.state.delivered"/>
            <state name="closed" display="oms.state.closed"/>
        </states>

        <transitions>
            <transition happy="true">
                <source>new</source>
                <target>paid</target>
                <event>pay</event>
            </transition>

            <transition happy="true" condition="MerchantSalesOrder/IsOrderPaid">
                <source>paid</source>
                <target>merchant split pending</target>
            </transition>

            <transition>
                <source>paid</source>
                <target>paid</target>
            </transition>

            <transition happy="true">
                <source>merchant split pending</source>
                <target>sent to merchant</target>
                <event>send to merchant</event>
            </transition>

            <transition>
                <source>sent to merchant</source>
                <target>canceled</target>
                <event>cancel</event>
            </transition>

            <transition>
                <source>canceled</source>
                <target>refunded</target>
                <event>refund</event>
            </transition>

            <transition>
                <source>refunded</source>
                <target>closed</target>
                <event>close</event>
            </transition>

            <transition happy="true">
                <source>sent to merchant</source>
                <target>shipped by merchant</target>
                <event>ship by merchant</event>
            </transition>

            <transition happy="true">
                <source>shipped by merchant</source>
                <target>delivered</target>
                <event>deliver</event>
            </transition>

            <transition happy="true">
                <source>delivered</source>
                <target>closed</target>
                <event>close</event>
            </transition>

        </transitions>

        <events>
            <event name="pay" manual="true"/>
            <event name="cancel" manual="true"/>
            <event name="refund" manual="true"/>
            <event name="send to merchant" onEnter="true" command="MerchantSalesOrder/CreateOrders"/>
            <event name="ship by merchant"/>
            <event name="deliver"/>
            <event name="close" manual="true" command="MerchantOms/CloseOrderItem"/>
        </events>
    </process>

</statemachine>
config/Zed/navigation.xml
<?xml version="1.0"?>
<config>
    <sales>
        <pages>
            <merchant-sales-order>
                <label>My orders</label>
                <title>My orders</title>
                <bundle>merchant-sales-order-merchant-user-gui</bundle>
                <controller>index</controller>
                <action>index</action>
                <visible>1</visible>
            </merchant-sales-order>
        </pages>
    </sales>
    <marketplace>
        <pages>
            <order-list>
                <label>Orders</label>
                <title>Orders</title>
                <bundle>sales</bundle>
                <controller>index</controller>
                <action>index</action>
            </order-list>
        </pages>
    </marketplace>
</config>

Execute the following command:

console navigation:build-cache
Verification

Make sure that, in the navigation menu of the Back Office, you can see the Marketplace->Orders as well as Sales->My Orders menu items.

3) Set up database schema and transfer objects

Apply database changes and generate entity and transfer changes:

console transfer:generate
console propel:install
console transfer:generate
Verification

Check your database to make sure that the following changes have been applied:

DATABASE ENTITY TYPE EVENT
spy_merchant.fk_state_machine_process column created
spy_merchant_sales_order_item.fk_state_machine_item_state column created
spy_merchant_sales_order table created
spy_merchant_sales_order_item table created
spy_merchant_sales_order_totals table created
spy_sales_expense.merchant_reference column created
spy_sales_order_item.merchant_reference column created
Verification

Make sure that the following changes have been triggered in transfer objects:

TRANSFER TYPE EVENT PATH
Merchant.fkStateMachineProcess property created src/Generated/Shared/Transfer/MerchantTransfer
MerchantOrder class created src/Generated/Shared/Transfer/MerchantOrderTransfer
MerchantOrderCriteria class created src/Generated/Shared/Transfer/MerchantOrderCriteriaTransfer
MerchantOrderCollection class created src/Generated/Shared/Transfer/MerchantOrderCollectionTransfer
MerchantOrderItem class created src/Generated/Shared/Transfer/MerchantOrderItemTransfer
MerchantOrderItemCriteria class created src/Generated/Shared/Transfer/MerchantOrderItemCriteriaTransfer
MerchantOrderItemCollection class created src/Generated/Shared/Transfer/MerchantOrderItemCollectionTransfer
MerchantOrderItemResponse class created src/Generated/Shared/Transfer/MerchantOrderItemResponseTransfer
MerchantOmsTriggerRequest class created src/Generated/Shared/Transfer/MerchantOmsTriggerRequestTransfer
MerchantOmsTriggerResponse class created src/Generated/Shared/Transfer/MerchantOmsTriggerResponseTransfer

4) Add translations

Generate a new translation cache for Zed:

console translator:generate-cache

5) Import data

Import data as follows:

  1. Prepare your data according to your requirements using the demo data:

data/import/common/common/marketplace/merchant_oms_process.csv

>merchant_reference,merchant_oms_process_name
MER000001,MainMerchantStateMachine
MER000002,MerchantDefaultStateMachine
MER000006,MerchantDefaultStateMachine
MER000004,MerchantDefaultStateMachine
MER000003,MerchantDefaultStateMachine
MER000007,MerchantDefaultStateMachine
MER000005,MerchantDefaultStateMachine
PAREMETER REQUIRED? TYPE DATA EXAMPLE DESCRIPTION
merchant_reference string spryker String identifier for merchant in the Spryker system.
merchant_oms_process_name string MainMerchantStateMachine String identifier for the State Machine processes.
  1. Register the following plugin to enable data import:
PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
MerchantOmsProcessDataImportPlugin Imports Merchant State Machine data Spryker\Zed\MerchantOmsDataImport\Communication\Plugin\DataImport

src/Pyz/Zed/DataImport/DataImportDependencyProvider.php

<?php

namespace Pyz\Zed\DataImport;

use Spryker\Zed\DataImport\DataImportDependencyProvider as SprykerDataImportDependencyProvider;
use Spryker\Zed\MerchantOmsDataImport\Communication\Plugin\DataImport;

class DataImportDependencyProvider extends SprykerDataImportDependencyProvider
{
    protected function getDataImporterPlugins(): array
    {
        return [
            new MerchantOmsProcessDataImportPlugin(),
        ];
    }
}
  1. Import data:
console data:import merchant-oms-process
Verification

Make sure that in the spy_merchant table, merchants have correct fk_process id in their columns.

6) Export data

Export data as follows:

  1. Create and prepare your data/export/config/merchant_order_export_config.yml file according to your requirements using our demo config template:
data/export/config/merchant_order_export_config.yml
version: 1

defaults:
    filter_criteria: &default_filter_criteria
        merchant_order_created_at:
            type: between
            from: '2020-05-01 00:00:00+09:00'
            to: '2021-12-31 23:59:59+09:00'
        merchant_order_updated_at:
            type: between
            from: '2021-01-08 09:00:12+12:00'
            to: '2021-12-31 23:59:59+09:00'

actions:
#Merchant orders data export
    - data_entity: merchant-order-expense
      destination: 'merchants/{merchant_name}/merchant-orders/{data_entity}s_{store_name}_{timestamp}.csv'
      filter_criteria:
          <<: *default_filter_criteria
          store_name: [DE]

    - data_entity: merchant-order-expense
      destination: 'merchants/{merchant_name}/merchant-orders/{data_entity}s_{store_name}_{timestamp}.csv'
      filter_criteria:
          <<: *default_filter_criteria
          store_name: [US]

    - data_entity: merchant-order-item
      destination: 'merchants/{merchant_name}/merchant-orders/{data_entity}s_{store_name}_{timestamp}.csv'
      filter_criteria:
          <<: *default_filter_criteria
          store_name: [DE]

    - data_entity: merchant-order-item
      destination: 'merchants/{merchant_name}/merchant-orders/{data_entity}s_{store_name}_{timestamp}.csv'
      filter_criteria:
          <<: *default_filter_criteria
          store_name: [US]

    - data_entity: merchant-order
      destination: 'merchants/{merchant_name}/merchant-orders/{data_entity}s_{store_name}_{timestamp}.csv'
      filter_criteria:
          <<: *default_filter_criteria
          store_name: [DE]

    - data_entity: merchant-order
      destination: 'merchants/{merchant_name}/merchant-orders/{data_entity}s_{store_name}_{timestamp}.csv'
      filter_criteria:
          <<: *default_filter_criteria
          store_name: [US]
PARAMETER REQUIRED POSSIBLE VALUES DESCRIPTION
data_entity merchant-order merchant-order-item merchant-order-expense String identifier for data entity that is expected to be exported.
filter_criteria store_name All existing store names. An existing store name for the data to filter on.
merchant_order_created_at from Date in format ‘YYYY-MM-DD HH:mm:ss HH24:MI’ Date of merchant order creation from which the data needs to be filtered.
to Date in format ‘YYYY-MM-DD HH:mm:ss HH24:MI’ Date of merchant order creation up to which the data needs to be filtered.
merchant_order_updated_at from Date in format ‘YYYY-MM-DD HH:mm:ss HH24:MI’ Date of merchant order update from which the data needs to be filtered.
to Date in format ‘YYYY-MM-DD HH:mm:ss HH24:MI’ Date of merchant order update up to which the data needs to be filtered.
  1. Register the following plugins to enable data export:
PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
MerchantOrderDataEntityExporterPlugin Exports merchant order data Spryker\Zed\MerchantSalesOrderDataExport\Communication\Plugin\DataExport
MerchantOrderItemDataEntityExporterPlugin Exports merchant order Items data Spryker\Zed\MerchantSalesOrderDataExport\Communication\Plugin\DataExport
MerchantOrderExpenseDataEntityExporterPlugin Exports merchant order Expense data Spryker\Zed\MerchantSalesOrderDataExport\Communication\Plugin\DataExport

src/Pyz/Zed/DataExport/DataExportDependencyProvider.php

<?php

namespace Pyz\Zed\DataExport;

use Spryker\Zed\DataExport\DataExportDependencyProvider as SprykerDataExportDependencyProvider;
use Spryker\Zed\MerchantSalesOrderDataExport\Communication\Plugin\DataExport\MerchantOrderDataEntityExporterPlugin;
use Spryker\Zed\MerchantSalesOrderDataExport\Communication\Plugin\DataExport\MerchantOrderExpenseDataEntityExporterPlugin;
use Spryker\Zed\MerchantSalesOrderDataExport\Communication\Plugin\DataExport\MerchantOrderItemDataEntityExporterPlugin;

class DataExportDependencyProvider extends SprykerDataExportDependencyProvider
{
    /**
     * @return \Spryker\Zed\DataExportExtension\Dependency\Plugin\DataEntityExporterPluginInterface[]
     */
    protected function getDataEntityExporterPlugins(): array
    {
        return [
            new MerchantOrderDataEntityExporterPlugin(),
            new MerchantOrderItemDataEntityExporterPlugin(),
            new MerchantOrderExpenseDataEntityExporterPlugin(),
        ];
    }
}
  1. Export data:
console data:export --config=merchant_order_export_config.yml

7) Set up behavior

Enable the following behaviors by registering the plugins:

PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
TriggerEventFromCsvFileConsole Allows for updating merchant order status via CSV input. Spryker\Zed\MerchantOms\Communication\Console
EventTriggerMerchantOrderPostCreatePlugin Triggers new events for the newly created merchant orders Spryker\Zed\MerchantOms\Communication\Plugin\MerchantSalesOrder
MerchantOmsMerchantOrderExpanderPlugin Expands merchant order with merchant Oms data (item state and manual events) Spryker\Zed\MerchantOms\Communication\Plugin\MerchantSalesOrder
MerchantStateMachineHandlerPlugin Wires merchant order updates in the State Machine module Spryker\Zed\MerchantOms\Communication\Plugin\StateMachine
MerchantOmsStateOrderItemsTableExpanderPlugin Expands the order item table with merchant order item state Spryker\Zed\MerchantOmsGui\Communication\Plugin\Sales
MerchantOrderDataOrderExpanderPlugin Expands order data with merchant order details Spryker\Zed\MerchantSalesOrder\Communication\Plugin\Sales
MerchantReferenceOrderItemExpanderPreSavePlugin Expands order item with merchant reference before saving an order item to the database Spryker\Zed\MerchantSalesOrder\Communication\Plugin\Sales
MerchantReferencesOrderExpanderPlugin Expands order with merchant references from order items Spryker\Zed\MerchantSalesOrder\Communication\Plugin\Sales
MerchantReferenceShipmentExpenseExpanderPlugin Expands expense transfer with merchant reference from items Spryker\Zed\MerchantSalesOrder\Communication\Plugin\Shipment
ProductOfferReferenceOrderItemExpanderPreSavePlugin Expands order item with product offer reference before saving the order item to the database Spryker\Zed\ProductOfferSales\Communication\Plugin\Sales
DeliverMarketplaceOrderItemCommandPlugin Triggers ‘deliver’ event on a marketplace order item. Pyz\Zed\MerchantOms\Communication\Plugin\Oms
ShipByMerchantMarketplaceOrderItemCommandPlugin Triggers ‘ship by merchant’ event on a marketplace order item. Pyz\Zed\MerchantOms\Communication\Plugin\Oms
CancelMarketplaceOrderItemCommandPlugin Triggers ‘ship by merchant’ event on a marketplace order item. Pyz\Zed\MerchantOms\Communication\Plugin\Oms
src/Pyz/Zed/MerchantOms/Communication/MerchantOmsCommunicationFactory.php
<?php

namespace Pyz\Zed\MerchantOms\Communication;

use Pyz\Zed\MerchantOms\MerchantOmsDependencyProvider;
use Spryker\Zed\MerchantOms\Communication\MerchantOmsCommunicationFactory as SprykerMerchantOmsCommunicationFactory;

/**
 * @method \Spryker\Zed\MerchantOms\MerchantOmsConfig getConfig()
 * @method \Spryker\Zed\MerchantOms\Business\MerchantOmsFacadeInterface getFacade()
 * @method \Spryker\Zed\MerchantOms\Persistence\MerchantOmsRepositoryInterface getRepository()
 */
class MerchantOmsCommunicationFactory extends SprykerMerchantOmsCommunicationFactory
{
    /**
     * @return \Pyz\Zed\Oms\Business\OmsFacadeInterface
     */
    public function getOmsFacade(): OmsFacadeInterface
    {
        return $this->getProvidedDependency(MerchantOmsDependencyProvider::FACADE_OMS);
    }
}
src/Pyz/Zed/Sales/SalesDependencyProvider.php
<?php

namespace Pyz\Zed\Sales;

use Spryker\Zed\MerchantOmsGui\Communication\Plugin\Sales\MerchantOmsStateOrderItemsTableExpanderPlugin;
use Spryker\Zed\MerchantSalesOrder\Communication\Plugin\Sales\MerchantOrderDataOrderExpanderPlugin;
use Spryker\Zed\MerchantSalesOrder\Communication\Plugin\Sales\MerchantReferenceOrderItemExpanderPreSavePlugin;
use Spryker\Zed\MerchantSalesOrder\Communication\Plugin\Sales\MerchantReferencesOrderExpanderPlugin;
use Spryker\Zed\ProductOfferSales\Communication\Plugin\Sales\ProductOfferReferenceOrderItemExpanderPreSavePlugin;
use Spryker\Zed\Sales\SalesDependencyProvider as SprykerSalesDependencyProvider;

class SalesDependencyProvider extends SprykerSalesDependencyProvider
{
    /**
     * @return \Spryker\Zed\SalesExtension\Dependency\Plugin\OrderExpanderPluginInterface[]
     */
    protected function getOrderHydrationPlugins(): array
    {
        return [
            new MerchantOrderDataOrderExpanderPlugin(),
            new MerchantReferencesOrderExpanderPlugin(),
        ];
    }

    /**
     * @return \Spryker\Zed\SalesExtension\Dependency\Plugin\OrderItemExpanderPreSavePluginInterface[]
     */
    protected function getOrderItemExpanderPreSavePlugins(): array
    {
        return [
            new MerchantReferenceOrderItemExpanderPreSavePlugin(),
            new ProductOfferReferenceOrderItemExpanderPreSavePlugin(),
        ];
    }

    /**
     * @return \Spryker\Zed\SalesExtension\Dependency\Plugin\OrderItemsTableExpanderPluginInterface[]
     */
    protected function getOrderItemsTableExpanderPlugins(): array
    {
        return [
            new MerchantOmsStateOrderItemsTableExpanderPlugin(),
        ];
    }
}
src/Pyz/Zed/Console/ConsoleDependencyProvider.php
<?php

namespace Pyz\Zed\Console;

use Spryker\Zed\Kernel\Container;
use Spryker\Zed\Console\ConsoleDependencyProvider as SprykerConsoleDependencyProvider;
use Spryker\Zed\MerchantOms\Communication\Console\TriggerEventFromCsvFileConsole;

class ConsoleDependencyProvider extends SprykerConsoleDependencyProvider
{
    /**
     * @param \Spryker\Zed\Kernel\Container $container
     *
     * @return \Symfony\Component\Console\Command\Command[]
     */
    protected function getConsoleCommands(Container $container): array
    {
        return [
            new TriggerEventFromCsvFileConsole(),
        ];
    }
}
src/Pyz/Zed/MerchantSalesOrder/MerchantSalesOrderDependencyProvider.php
<?php

namespace Pyz\Zed\MerchantSalesOrder;

use Spryker\Zed\MerchantOms\Communication\Plugin\MerchantSalesOrder\EventTriggerMerchantOrderPostCreatePlugin;
use Spryker\Zed\MerchantOms\Communication\Plugin\MerchantSalesOrder\MerchantOmsMerchantOrderExpanderPlugin;
use Spryker\Zed\MerchantSalesOrder\MerchantSalesOrderDependencyProvider as SprykerMerchantSalesOrderDependencyProvider;

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

    /**
     * @return \Spryker\Zed\MerchantSalesOrderExtension\Dependency\Plugin\MerchantOrderExpanderPluginInterface[]
     */
    protected function getMerchantOrderExpanderPlugins(): array
    {
        return [
            new MerchantOmsMerchantOrderExpanderPlugin(),
        ];
    }
}
src/Pyz/Zed/StateMachine/StateMachineDependencyProvider.php
<?php

/**
 * This file is part of the Spryker Suite.
 * For full license information, view the LICENSE file that was distributed with this source code.
 */

namespace Pyz\Zed\StateMachine;

use Spryker\Zed\MerchantOms\Communication\Plugin\StateMachine\MerchantStateMachineHandlerPlugin;
use Spryker\Zed\StateMachine\StateMachineDependencyProvider as SprykerStateMachineDependencyProvider;

class StateMachineDependencyProvider extends SprykerStateMachineDependencyProvider
{
    /**
     * @return \Spryker\Zed\StateMachine\Dependency\Plugin\StateMachineHandlerInterface[]
     */
    protected function getStateMachineHandlers()
    {
        return [
            new MerchantStateMachineHandlerPlugin(),
        ];
    }
src/Pyz/Zed/Shipment/ShipmentDependencyProvider.php
<?php

namespace Pyz\Zed\Shipment;

use Spryker\Zed\MerchantSalesOrder\Communication\Plugin\Shipment\MerchantReferenceShipmentExpenseExpanderPlugin;
use Spryker\Zed\Shipment\ShipmentDependencyProvider as SprykerShipmentDependencyProvider;

class ShipmentDependencyProvider extends SprykerShipmentDependencyProvider
{
    /**
     * @return \Spryker\Zed\ShipmentExtension\Dependency\Plugin\ShipmentExpenseExpanderPluginInterface[]
     */
    protected function getShipmentExpenseExpanderPlugins(): array
    {
        return [
            new MerchantReferenceShipmentExpenseExpanderPlugin(),
        ];
    }
}

src/Pyz/Zed/MerchantOms/Communication/Plugin/Oms/DeliverMarketplaceOrderItemCommandPlugin.php
<?php

namespace Pyz\Zed\MerchantOms\Communication\Plugin\Oms;

class DeliverMarketplaceOrderItemCommandPlugin extends AbstractTriggerOmsEventCommandPlugin
{
    protected const EVENT_DELIVER = 'deliver';

    /**
     * @return string
     */
    public function getEventName(): string
    {
        return static::EVENT_DELIVER;
    }
}

src/Pyz/Zed/MerchantOms/Communication/Plugin/Oms/ShipByMerchantMarketplaceOrderItemCommandPlugin.php
<?php

namespace Pyz\Zed\MerchantOms\Communication\Plugin\Oms;

class ShipByMerchantMarketplaceOrderItemCommandPlugin extends AbstractTriggerOmsEventCommandPlugin
{
    protected const EVENT_SHIP_BY_MERCHANT = 'ship by merchant';

    /**
     * @return string
     */
    public function getEventName(): string
    {
        return static::EVENT_SHIP_BY_MERCHANT;
    }
}
src/Pyz/Zed/MerchantOms/Communication/Plugin/Oms/CancelMarketplaceOrderItemCommandPlugin.php
<?php

namespace Pyz\Zed\MerchantOms\Communication\Plugin\Oms;

class CancelMarketplaceOrderItemCommandPlugin extends AbstractTriggerOmsEventCommandPlugin
{
    /**
     * @var string
     */
    protected const EVENT_CANCEL = 'cancel';

    /**
     * @return string
     */
    public function getEventName(): string
    {
        return static::EVENT_CANCEL;
    }
}
src/Pyz/Zed/MerchantOms/MerchantOmsDependencyProvider.php
<?php

namespace Pyz\Zed\MerchantOms;

use Pyz\Zed\MerchantOms\Communication\Plugin\Oms\CancelMarketplaceOrderItemCommandPlugin;
use Pyz\Zed\MerchantOms\Communication\Plugin\Oms\DeliverMarketplaceOrderItemCommandPlugin;
use Pyz\Zed\MerchantOms\Communication\Plugin\Oms\ShipByMerchantMarketplaceOrderItemCommandPlugin;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\MerchantOms\MerchantOmsDependencyProvider as SprykerMerchantOmsDependencyProvider;

class MerchantOmsDependencyProvider extends SprykerMerchantOmsDependencyProvider
{
    protected function getStateMachineCommandPlugins(): array
    {
        return [
            'MarketplaceOrder/ShipOrderItem' => new ShipByMerchantMarketplaceOrderItemCommandPlugin(),
            'MarketplaceOrder/DeliverOrderItem' => new DeliverMarketplaceOrderItemCommandPlugin(),
            'MarketplaceOrder/CancelOrderItem' => new CancelMarketplaceOrderItemCommandPlugin(),
        ];
    }
}
Verification

Make sure that the Merchant State Machine is executed on merchant orders after the order has been split.

Make sure that when retrieving an order in the Sales module, it is split by the merchant order and that the Order state is derived from the Merchant State Machine.

Install feature front end

Follow the steps below to install the Marketplace Order Management feature front end.

Prerequisites

To start feature integration, integrate the required features:

NAME VERSION INTEGRATION GUIDE
Spryker Core 202108.0 Spryker Core feature integration

1) Install the required modules using Сomposer

If installed before, not needed.

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
SalesMerchantPortalGui spryker/sales-merchant-portal-gui

2) Set up transfers

Apply database changes and to generate entity and transfer changes:

console transfer:generate
Verification

Ensure the following transfers have been created:

TRANSFER TYPE EVENT PATH
MerchantOrderTableCriteria class created src/Generated/Shared/Transfer/MerchantOrderCriteriaTransfer
MerchantOrderItemTableCriteria class created src/Generated/Shared/Transfer/DataImporterConfigurationTransfer

3) Set up plugins

Register the following plugins to enable widgets:

PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
OrdersMerchantDashboardCardPlugin Adds the Sales widget to MerchantDashboard Spryker\Zed\SalesMerchantPortalGui\Communication\Plugin
src/Pyz/Zed/DashboardMerchantPortalGui/DashboardMerchantPortalGuiDependencyProvider.php
<?php

namespace Pyz\Zed\DashboardMerchantPortalGui;

use Spryker\Zed\DashboardMerchantPortalGui\DashboardMerchantPortalGuiDependencyProvider as SprykerDashboardMerchantPortalGuiDependencyProvider;
use Spryker\Zed\SalesMerchantPortalGui\Communication\Plugin\DashboardMerchantPortalGui\OrdersMerchantDashboardCardPlugin;

class DashboardMerchantPortalGuiDependencyProvider extends SprykerDashboardMerchantPortalGuiDependencyProvider
{
    protected function getDashboardCardPlugins(): array
    {
        return [
            new OrdersMerchantDashboardCardPlugin(),
        ];
    }
}

Verification

Make sure that the following widgets have been registered by adding the respective code snippets to a Twig template:

WIDGET VERIFICATION
SalesMerchantPortalGui Open MerchantDashboard at http://mysprykershop.com/dashboard-merchant-portal-gui and check that the Sales widget is available.

Integrate the following related features:

FEATURE REQUIRED FOR THE CURRENT FEATURE INTEGRATION GUIDE
Marketplace Order Management + Order Threshold Marketplace Order Management + Order Threshold feature integration
Marketplace Order Management + Cart Marketplace Order Management + Cart feature integration
Marketplace Inventory Management + Marketplace Order Management Marketplace Inventory Management + Marketplace Order Management feature integration