GLUE API - Promotions and Discounts feature integration
Edit on GitHub
You are browsing a previous version of the document. The latest version is 202212.0.
Install feature API
Prerequisites
To start feature integration, overview and install the necessary features:
Name | Version | Integration guide |
---|---|---|
Spryker Core | 201907.0 | Glue Application feature integration |
Product | 201907.0 | Products feature integration |
Promotions & Discounts | 201907.0 | None |
1) Install the required modules using Composer
Run the following command(s) to install the required modules:
composer require spryker/product-labels-rest-api:"^1.0.0" --update-with-dependencies
Verification
Make sure that the following modules were installed:
Module | Expected Directory |
---|---|
ProductLabelsRestApi |
vendor/spryker/product-labels-rest-api |
2) Set up Transfer Objects
Run the following commands to generate transfer changes:
console transfer:generate
Verification
Make sure that the following changes have been applied in transfer objects:
Transfer | Type | Event | Path |
---|---|---|---|
RestProductLabelsAttributesTransfer |
class | created | src/Generated/Shared/Transfer/RestProductLabelsAttributesTransfer |
3) Set up Behavior
Enable resources and relationships
Activate the following plugin:
Plugin | Specification | Prerequisites | Namespace |
---|---|---|---|
ProductLabelsRelationshipByResourceIdPlugin |
Adds a product labels resource as a relationship to the abstract product resource. | None | Spryker\Glue\ProductLabelsRestApi\Plugin\GlueApplication |
ProductLabelsResourceRoutePlugin |
Registers a product labels resource. | None | Spryker\Glue\ProductLabelsRestApi\Plugin\GlueApplication |
src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php
<?php
namespace Pyz\Glue\GlueApplication;
use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
use Spryker\Glue\ProductLabelsRestApi\Plugin\GlueApplication\ProductLabelsRelationshipByResourceIdPlugin;
use Spryker\Glue\ProductLabelsRestApi\Plugin\GlueApplication\ProductLabelsResourceRoutePlugin;
use Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface;
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig;
class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
/**
* @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
*/
protected function getResourceRoutePlugins(): array
{
return [
new ProductLabelsResourceRoutePlugin(),
];
}
/**
* @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 ProductLabelsRelationshipByResourceIdPlugin()
);
return $resourceRelationshipCollection;
}
}
Verification
Make sure that the following endpoint is available: https://glue.mysprykershop.comm/product-labels/{{abstract_sku}}
Send a request to https://glue.mysprykershop.comom/abstract-products/{{sku}}?include=product-labels` and verify if the abstract product with a given SKU has at least one assigned product label and the response includes relationships to product-labels resources.)
Thank you!
For submitting the form