Install the Marketplace Product Glue API
Edit on GitHubThis document describes how to integrate the Marketplace Product Glue API feature into a Spryker project.
Install feature core
Follow the steps below to install the Marketplace Product Glue API feature core.
Prerequisites
Install the required features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Spryker Core | 202404.0 | Install the Spryker Core Glue API |
Marketplace Product | 202404.0 | Install the Marketplace Product feature |
1) Install the required modules
Install the required modules using Composer:
composer require spryker/merchant-products-rest-api:"^1.0.0" --update-with-dependencies
Make sure that the following modules have been installed:
MODULE | EXPECTED DIRECTORY |
---|---|
MerchantProductsRestApi | vendor/spryker/merchant-products-rest-api |
2) Set up transfer objects
Generate transfer changes:
console transfer:generate
Make sure the following changes have been applied in transfer objects:
TRANSFER | TYPE | EVENT | PATH |
---|---|---|---|
AbstractProductsRestAttributes.merchantReference | property | Created | src/Generated/Shared/Transfer/AbstractProductsRestAttributesTransfer |
RestCartItemsAttributes.merchantReference | property | Created | src/Generated/Shared/Transfer/RestCartItemsAttributesTransfer |
CartItemRequest.merchantReference | property | Created | src/Generated/Shared/Transfer/CartItemRequestTransfer |
3) Set up behavior
Enable the following behaviors by registering the plugins:
PLUGIN | DESCRIPTION | 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\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
use Spryker\Glue\MerchantsRestApi\Plugin\GlueApplication\MerchantByMerchantReferenceResourceRelationshipPlugin;
use Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface;
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig;
use Spryker\Glue\SharedCartsRestApi\SharedCartsRestApiConfig;
class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
/**
* @param \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface $resourceRelationshipCollection
*
* @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface
*/
protected function getResourceRelationshipPlugins(
ResourceRelationshipCollectionInterface $resourceRelationshipCollection
): ResourceRelationshipCollectionInterface {
$resourceRelationshipCollection->addRelationship(
ProductsRestApiConfig::RESOURCE_ABSTRACT_PRODUCTS,
new MerchantByMerchantReferenceResourceRelationshipPlugin()
);
$resourceRelationshipCollection->addRelationship(
CartsRestApiConfig::RESOURCE_CART_ITEMS,
new MerchantByMerchantReferenceResourceRelationshipPlugin()
);
$resourceRelationshipCollection->addRelationship(
CartsRestApiConfig::RESOURCE_GUEST_CARTS_ITEMS,
new MerchantByMerchantReferenceResourceRelationshipPlugin()
);
return $resourceRelationshipCollection;
}
}
Make sure that when you do a GET
request to retrieve abstract products that belong to a specific merchant, it returns products’ data together with their merchants http://glue.de.demo-spryker.com/abstract-products/{{abstractProductSku}}?include=merchants
.
Install related features
FEATURE | REQUIRED FOR THE CURRENT FEATURE | INSTALLATION GUIDE |
---|---|---|
Marketplace Product + Cart API | Install the Marketplace Product + Cart Glue API |
Thank you!
For submitting the form