Glue API - Product relations feature integration

Edit on GitHub

Install Feature API

Follow the steps to install the Product Relations feature API.

Prerequisites

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

NAME VERSION REQUIRED SUB-FEATURE
Spryker Core 202108.0 Glue Application
Product Relation master
Cart 202108.0 Cart API
Product 202108.0 Products API

1) Install the required modules using Composer

Run the following command to install the required modules:

composer require spryker/related-products-rest-api:"^1.0.0" spryker/up-selling-products-rest-api:"^1.0.0" --update-with-dependencies
“Verification”

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
RelatedProductsRestApi vendor/spryker/related-products-rest-api
UpSellingProductsRestApi vendor/spryker/up-selling-products-rest-api

2) Set up behavior

Set up the following behavior.

Enable resources and relationships

Activate the following plugins:

PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
RelatedProductsResourceRoutePlugin Retrieves the related products collection. None Spryker\Glue\RelatedProductsRestApi\Plugin\GlueApplication
CartUpSellingProductsResourceRoutePlugin Retrieves the up-selling products collection for the cart. None `Spryker\Glue\UpSellingProductsRestApi\Plugin\GlueApplication
GuestCartUpSellingProductsResourceRoutePlugin Retrieves the up-selling products collection for the guest cart. None Spryker\Glue\UpSellingProductsRestApi\Plugin\GlueApplication

src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php

<?php
 
namespace Pyz\Glue\GlueApplication;
 
use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
use Spryker\Glue\RelatedProductsRestApi\Plugin\GlueApplication\RelatedProductsResourceRoutePlugin;
use Spryker\Glue\UpSellingProductsRestApi\Plugin\GlueApplication\CartUpSellingProductsResourceRoutePlugin;
use Spryker\Glue\UpSellingProductsRestApi\Plugin\GlueApplication\GuestCartUpSellingProductsResourceRoutePlugin;
 
class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
    /**
     * @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
     */
    protected function getResourceRoutePlugins(): array
     {
        return [
            new RelatedProductsResourceRoutePlugin(),
            new CartUpSellingProductsResourceRoutePlugin(),
            new GuestCartUpSellingProductsResourceRoutePlugin(),
        ];
    }
}
Verification

Make sure that the following endpoints are available: http://glue.mysprykershop.com/abstract-products/{{abstract_product_sku}}e/related-products http://glue.mysprykershop.com/carts/{{cart_uuid}}/up-selling-products http://glue.mysprykershop.com/guest-carts/{{guest_cart_uuid}}/up-selling-products