Product + order management feature integration

Edit on GitHub

Install feature core

Prerequisites

To start feature integration, overview and install the necessary features:

NAME VERSION
Product 202108.0
Order Management 202108.0
Spryker Core 202108.0

1) Install the required modules using Composer

Run the following command(s) to install the required modules:

composer require spryker/sales-product-connector:"^1.4.0" --update-with-dependencies
Verification

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
SalesProductConnector vendor/spryker/sales-product-connector

2) Set up transfer objects

Run the following command to generate transfer changes:

console transfer:generate
Verification

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

TRANSFER TYPE EVENT PATH
Order.idSalesOrder property Created src/Generated/Shared/Transfer/OrderTransfer
Item.fkSalesOrder property Created src/Generated/Shared/Transfer/ItemTransfer

3) Set up behavior

Register the following plugins:

PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
ItemMetadataSearchOrderExpanderPlugin Expands items of each order with metadata information. None Spryker\Zed\SalesProductConnector\Communication\Plugin\Sales
MetadataOrderItemExpanderPlugin Expands order items with metadata information. None Spryker\Zed\SalesProductConnector\Communication\Plugin\Sales
ProductIdOrderItemExpanderPlugin Expands order items with abstract and concrete product ids. None Spryker\Zed\SalesProductConnector\Communication\Plugin\Sales

/src/Pyz/Zed/Sales/SalesDependencyProvider.php

<?php

namespace Pyz\Zed\Sales;

use Spryker\Zed\Sales\SalesDependencyProvider as SprykerSalesDependencyProvider;
use Spryker\Zed\SalesProductConnector\Communication\Plugin\Sales\ItemMetadataSearchOrderExpanderPlugin;
use Spryker\Zed\SalesProductConnector\Communication\Plugin\Sales\MetadataOrderItemExpanderPlugin;
use Spryker\Zed\SalesProductConnector\Communication\Plugin\Sales\ProductIdOrderItemExpanderPlugin;

class SalesDependencyProvider extends SprykerSalesDependencyProvider
{
    /**
     * @return \Spryker\Zed\SalesExtension\Dependency\Plugin\SearchOrderExpanderPluginInterface[]
     */
    protected function getSearchOrderExpanderPlugins(): array
    {
        return [
            new ItemMetadataSearchOrderExpanderPlugin(),
        ];
    }

    /**
     * @return \Spryker\Zed\SalesExtension\Dependency\Plugin\OrderItemExpanderPluginInterface[]
     */
    protected function getOrderItemExpanderPlugins(): array
    {
        return [
            new MetadataOrderItemExpanderPlugin(),
            new ProductIdOrderItemExpanderPlugin(),
        ];
    }
}
Verification

Make sure that every order item from SalesFacade::searchOrders() results contain metadata information.

Verification

Make sure that every order item from SalesFacade::getOrderItems() results contain product concrete/abstract IDs data. Make sure that every order item from SalesFacade::getOrderItems() results contain metadata information.