Glue API: Marketplace Inventory Management feature integration

Edit on GitHub

This document describes how to integrate the Marketplace Inventory Management Glue API feature into a Spryker project.

Install feature core

Follow the steps below to install the Marketplace Inventory Management Glue API feature core.

Prerequisites

To start feature integration, integrate the required features:

NAME VERSION INTEGRATION GUIDE
Spryker Core 202108.0 Glue API: Spryker Core feature integration
Marketplace Inventory Management 202108.0 Marketplace Inventory Management feature integration

1) Install the required modules using Composer

Install the required modules:

composer require spryker/product-offer-availabilities-rest-api:"^0.4.0" --update-with-dependencies
Verification

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
ProductOfferAvailabilitiesRestApi vendor/spryker/product-offer-availabilities-rest-api

2) 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
RestProductOfferAvailabilitiesAttributes object Created src/Generated/Shared/Transfer/RestProductOfferAvailabilitiesAttributesTransfer

3) Enable resources and relationships

Activate the following plugins:

PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
ProductOfferAvailabilitiesResourceRoutePlugin Registers the product-offer-availabilities resource. Spryker\Glue\ProductOfferAvailabilitiesRestApi\Plugin\GlueApplication
ProductOfferAvailabilitiesByProductOfferReferenceResourceRelationshipPlugin Adds the product-offer-availabilities resource as a relationship of the product-offers resource. Spryker\Glue\ProductOfferAvailabilitiesRestApi\Plugin\GlueApplication
src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php
<?php

namespace Pyz\Glue\GlueApplication;

use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
use Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface;
use Spryker\Glue\MerchantProductOffersRestApi\MerchantProductOffersRestApiConfig;
use Spryker\Glue\ProductOfferAvailabilitiesRestApi\Plugin\GlueApplication\ProductOfferAvailabilitiesByProductOfferReferenceResourceRelationshipPlugin;
use Spryker\Glue\ProductOfferAvailabilitiesRestApi\Plugin\GlueApplication\ProductOfferAvailabilitiesResourceRoutePlugin;

class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
    /**
     * @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
     */
    protected function getResourceRoutePlugins(): array
    {
        return [
            new ProductOfferAvailabilitiesResourceRoutePlugin(),
        ];
    }

    /**
     * @param \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface $resourceRelationshipCollection
     *
     * @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface
     */
    protected function getResourceRelationshipPlugins(
        ResourceRelationshipCollectionInterface $resourceRelationshipCollection
    ): ResourceRelationshipCollectionInterface {
        $resourceRelationshipCollection->addRelationship(
            MerchantProductOffersRestApiConfig::RESOURCE_PRODUCT_OFFERS,
            new ProductOfferAvailabilitiesByProductOfferReferenceResourceRelationshipPlugin()
        );

        return $resourceRelationshipCollection;
    }
}
Verification

Make sure that the ProductOfferAvailabilitiesResourceRoutePlugin plugin is set up by sending the request GET http://glue.mysprykershop.com/product-offers/{{productOfferReference}}/product-offer-availabilities.

Make sure that ProductOfferAvailabilitiesByProductOfferReferenceResourceRelationshipPlugin is set up by sending the request GET http://glue.mysprykershop.com{{url}}/product-offers/{{productOfferReference}}?include=product-offer-availabilities. The response should include the product-offer-availabilities resource along with product-offers.