Glue API: Marketplace Product + Cart feature integration

Edit on GitHub

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

Install feature core

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

Prerequisites

To start feature integration, integrate the required features:

NAME VERSION INTEGRATION GUIDE
Cart API 202108.0 Glue API: Cart feature integration
Marketplace Product API 202108.0 Glue API: Marketplace Product feature integration

1) Set up behavior

Enable the following behaviors by registering the plugins:

PLUGIN DESCRIPTION PREREQUISITES NAMESPACE
MerchantProductCartItemExpanderPlugin Expands view data for abstract product with merchant data. Spryker\Glue\MerchantProductsRestApi\Plugin\CartsRestApi

src/Pyz/Glue/CartsRestApi/CartsRestApiDependencyProvider.php

<?php

namespace Pyz\Glue\CartsRestApi;

use Spryker\Glue\CartsRestApi\CartsRestApiDependencyProvider as SprykerCartsRestApiDependencyProvider;
use Spryker\Glue\MerchantProductsRestApi\Plugin\CartsRestApi\MerchantProductCartItemExpanderPlugin;

class CartsRestApiDependencyProvider extends SprykerCartsRestApiDependencyProvider
{
    /**
     * @return \Spryker\Glue\CartsRestApiExtension\Dependency\Plugin\CartItemExpanderPluginInterface[]
     */
    protected function getCartItemExpanderPlugins(): array
    {
        return [
            new MerchantProductCartItemExpanderPlugin(),
        ];
    }
}
Verification

Make sure that you can add a merchant product to the cart using a POST request to http://glue.de.demo-spryker.com/guest-cart-items or http://glue.de.demo-spryker.com/carts/{{idCart}}/items.

Make sure that when you do a GET request for the carts with merchant products, their merchants are returned as well. http://glue.de.demo-spryker.com/guest-carts/{idCart}?include=guest-cart-items,merchants or http://glue.de.demo-spryker.com/carts/{{idCart}}?include=items,merchants.