Marketplace Shipment feature integration

Edit on GitHub
You are browsing a previous version of the document. The latest version is 202204.0.

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

Install feature core

Follow the steps below to install the Marketplace Shipment feature core.

Prerequisites

To start feature integration, integrate the required features:

NAME VERSION INTEGRATION GUIDE
Merchant 202108.0 Merchant feature integration
Shipment 202108.0 Shipment feature integration

1) Install the required modules using Composer

Install the required modules:

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

Make sure that the following modules were installed:

MODULE EXPECTED DIRECTORY
MerchantShipment vendor/spryker/merchant-shipment
MerchantShipmentGui vendor/spryker/merchant-shipment-gui

2) Set up configuration

Add the following configuration to your project:

CONFIGURATION SPECIFICATION NAMESPACE
ShipmentConfig::getShipmentHashFields() Used to group items by shipment using merchant reference. \Pyz\Service\Shipment

src/Pyz/Service/Shipment/ShipmentConfig.php

<?php

namespace Pyz\Service\Shipment;

use Generated\Shared\Transfer\ShipmentTransfer;
use Spryker\Service\Shipment\ShipmentConfig as SprykerShipmentConfig;

class ShipmentConfig extends SprykerShipmentConfig
{
    /**
     * @return array<string>
     */
    public function getShipmentHashFields(): array
    {
        return array_merge(parent::getShipmentHashFields(), [ShipmentTransfer::MERCHANT_REFERENCE]);
    }
}
Verification

Place an order and check that items are grouped by merchant shipment in backoffice.

3) Set up the database schema and transfer definitions

Apply the database changes and generate entity and transfer changes:

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

Verify that the following changes have been applied by checking your database:

DATABASE ENTITY TYPE EVENT
spy_sales_shipment.merchant_reference column created

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

TRANSFER TYPE EVENT PATH
MerchantShipmentCriteria class created src/Generated/Shared/Transfer/MerchantShipmentCriteria
Shipment.merchantReference property created src/Generated/Shared/Transfer/ShipmentTransfer

4) Set up behavior

Enable the following behaviors by registering the plugins:

PLUGIN DESCRIPTION PREREQUISITES NAMESPACE
MerchantShipmentOrderItemTemplatePlugin Shows merchant shipment in shipment section of the ShipmentGui::SalesController Spryker\Zed\MerchantShipmentGui\Communication\ShipmentGui

src/Pyz/Zed/ShipmentGui/ShipmentGuiDependencyProvider.php

<?php

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

namespace Pyz\Zed\ShipmentGui;

use Spryker\Zed\MerchantShipmentGui\Communication\ShipmentGui\MerchantShipmentOrderItemTemplatePlugin;
use Spryker\Zed\ShipmentGui\ShipmentGuiDependencyProvider as SprykerShipmentGuiDependencyProvider;

class ShipmentGuiDependencyProvider extends SprykerShipmentGuiDependencyProvider
{
    /**
     * @return array<\Spryker\Zed\ShipmentGuiExtension\Dependency\Plugin\ShipmentOrderItemTemplatePluginInterface>
     */
    protected function getShipmentOrderItemTemplatePlugins(): array
    {
        return [
            new MerchantShipmentOrderItemTemplatePlugin(),
        ];
    }
}
FEATURE REQUIRED FOR THE CURRENT FEATURE INTEGRATION GUIDE
Marketplace Shipment + Cart Marketplace Shipment + Cart feature integration
Marketplace Shipment + Checkout Marketplace Shipment + Checkout feature integration
Marketplace Shipment + Customer Marketplace Shipment + Customer feature integration