Glue API: Marketplace Return Management feature integration

Edit on GitHub
You are browsing a previous version of the document. The latest version is 202204.0.

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:"^1.0.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
RestReturnsAttributes.merchantReference attribute created src/Generated/Shared/Transfer/RestReturnsAttributesTransfer

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 https://glue.mysprykershop.com/returns/{{returnId}}include=merchants.

Verify that the returned data includes merchant resource attributes.

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

Verify that the returned data includes the merchantReference.