Install the Product Relations Glue API

Edit on GitHub

Install Feature API

Follow the steps to install the Product Relations feature API.

Prerequisites

Install the required features:

NAME VERSION REQUIRED SUB-FEATURE
Spryker Core 202307.0 Glue Application
Product Relation 202307.0 Install the Product Relations feature
Cart 202307.0 Cart API
Product 202307.0 Products API

1) Install the required modules

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:

  • https://glue.mysprykershop.com/abstract-products/{{abstract_product_sku}}e/related-products
  • https://glue.mysprykershop.com/carts/{{cart_uuid}}/up-selling-products
  • https://glue.mysprykershop.com/guest-carts/{{guest_cart_uuid}}/up-selling-products