Glue API - Product Labels feature integration
Edit on GitHub
You are browsing a previous version of the document. The latest version is 202212.0.
Follow the steps below to install Product Labels Feature API.
Prerequisites
To start feature integration, overview and install the necessary features:
Name | Version | Required Sub-Feature |
---|---|---|
Glue API: Glue Application | 201903.0 | Glue Application feature integration |
Glue API: Product | 201903.0 | Products API feature integration |
Product Label | 201903.0 |
1) Install the required modules using Composer
Run the following command to install the required modules:
composer require spryker/product-labels-rest-api:"^1.0.1" --update-with-dependencies
Make sure that the following module is 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
Make sure that the following changes are present in transfer objects:
Transfer | Type | Event | Path |
---|---|---|---|
RestProductLabelsAttributesTransfer |
class | created | src/Generated/Shared/Transfer/RestProductLabelsAttributesTransfer |
3) Set up Behavior
Set up the following behaviors.
Enable Resources and Relationships
Activate the following plugin:
Plugin | Specification | Prerequisites | Namespace |
---|---|---|---|
ProductLabelsRelationshipByResourceIdPlugin |
Adds the product labels resource as a relationship to the abstract product resource. | None | Spryker\Glue\ProductLabelsRestApi\Plugin\GlueApplication\ProductLabelsRelationshipByResourceIdPlugin |
ProductLabelsResourceRoutePlugin |
Registers the product labels resource. | None | Spryker\Glue\ProductLabelsRestApi\Plugin\GlueApplication\ProductLabelsResourceRoutePlugin |
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;
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 the following endpoint is available: https://glue.mysprykershop.com/product-labels/{{abstract_sku}}
Send a request to http://mysprykershop.com/abstract-products/{{sku}}?include=product-labels
and verify if the abstract product with the given SKU has at least one assigned product label and the response includes relationships to the product-labels resources.
Thank you!
For submitting the form