Marketplace Product + Cart feature integration

Edit on GitHub

This document describes how to integrate the Marketplace Product + Cart feature into a Spryker project.

Install feature core

Follow the steps below to install the Marketplace Product + Cart feature core.

Prerequisites

To start feature integration, integrate the required features:

NAME VERSION INTEGRATION GUIDE
Spryker Core 202108.0 Spryker Core feature integration
Marketplace Product 202108.0 Marketplace Product feature integration
Cart 202108.0 Cart Feature Integration

1) Set up transfer objects

Generate transfer changes:

console transfer:generate
Verification

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

TRANSFER TYPE EVENT PATH
Item.merchantReference property Created src/Generated/Shared/Transfer/ItemTransfer

2) Set up behavior

Enable the following behaviors by registering the plugins:

PLUGIN DESCRIPTION PREREQUISITES NAMESPACE
MerchantProductCartPreCheckPlugin Validates that merchant references in the cart items match existing merchant products. Spryker\Zed\MerchantProduct\Communication\Plugin\Cart

src/Pyz/Zed/Merchant/MerchantDependencyProvider.php

<?php

namespace Pyz\Zed\Cart;

use Spryker\Zed\Cart\CartDependencyProvider as SprykerCartDependencyProvider;
use Spryker\Zed\Kernel\Container;
use Spryker\Zed\Merchant\Communication\Plugin\Cart\MerchantCartPreCheckPlugin;

class CartDependencyProvider extends SprykerCartDependencyProvider
{
    /**
     * @param \Spryker\Zed\Kernel\Container $container
     *
     * @return \Spryker\Zed\CartExtension\Dependency\Plugin\CartPreCheckPluginInterface[]
     */
    protected function getCartPreCheckPlugins(Container $container): array
    {
        return [
            new MerchantProductCartPreCheckPlugin(),
        ];
    }
}
Verification

Make sure that you can’t add an item with merchantReference and sku that do not belong to the same MerchantProduct(see spy_merchant_product_abstract).