Glue API: Marketplace Return Management feature integration

Edit on GitHub

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

Install feature core

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

Prerequisites

To start feature integration, integrate the required features:

NAME VERSION INTEGRATION GUIDE
Marketplace Merchant 202108.0 Marketplace Merchant feature integration
Marketplace Return Management 202108.0 Marketplace Return Management feature integration

1) Install the required modules using Сomposer

Install the required modules:

composer require spryker/merchant-sales-returns-rest-api:"^0.2.0" --update-with-dependencies
Verification

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
MerchantSalesReturnsRestApi spryker/merchant-sales-returns-rest-api

2) Set up transfer objects

Generate transfers:

console transfer:generate
Verification

Ensure the following transfers have been created:

TRANSFER TYPE EVENT PATH
Return.merchantReference attribute created src/Generated/Shared/Transfer/ReturnTransfer
ReturnCollection class created src/Generated/Shared/Transfer/ReturnCollectionTransfer
RestReturnsAttributes class created src/Generated/Shared/Transfer/RestReturnsAttributesTransfer
RestOrderItemsAttributes class created src/Generated/Shared/Transfer/RestOrderItemsAttributesTransfer
ReturnResponse.messages attribute created src/Generated/Shared/Transfer/ReturnResponseTransfer

3) Set up behavior

Enable the following behaviors by registering the plugins:

PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
MerchantByMerchantReferenceResourceRelationshipPlugin Adds merchants resources as relationship by merchant references in the attributes Spryker\Glue\MerchantsRestApi\Plugin\GlueApplication
src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php
<?php

namespace Pyz\Glue\GlueApplication;

use Spryker\Glue\MerchantsRestApi\Plugin\GlueApplication\MerchantByMerchantReferenceResourceRelationshipPlugin;
use Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface;

class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
  protected function getResourceRelationshipPlugins(
          ResourceRelationshipCollectionInterface $resourceRelationshipCollection
      ): ResourceRelationshipCollectionInterface {
          $resourceRelationshipCollection->addRelationship(
                SalesReturnsRestApiConfig::RESOURCE_RETURNS,
                new MerchantByMerchantReferenceResourceRelationshipPlugin()
            );

            return $resourceRelationshipCollection;
      }

}
Verification

Make sure that the MerchantByMerchantReferenceResourceRelationshipPlugin plugin is set up by:

  1. Sending the request GET http://glue.mysprykershop.com/returns/{{returnId}}include=merchants.

Verify that the returned data includes merchant resource attributes.

  1. Sending the request GET http://glue.mysprykershop.com/returns.

Verify that the returned data includes the merchantReference.