Install the Inventory Management Glue API
Edit on GitHubThis document describes how to install the Inventory Management feature API.
Prerequisites
Install the required features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Spryker Core | 202311.0 | Install the Spryker Core Glue API |
Product | 202311.0 | Install the Product Glue API |
Inventory Management | 202311.0 |
1) Install the required modules
Install the required modules using Composer:
composer require spryker/product-availabilities-rest-api:"^2.0.0" --update-with-dependencies
Make sure that the following modules have been installed:
MODULE | EXPECTED DIRECTORY |
---|---|
ProductAvailabilitiesRestApi | vendor/spryker/product-availabilities-rest-api |
ProductsRestApi | vendor/spryker/products-rest-api |
2) Set up transfer objects
Generate transfer changes:
console transfer:generate
Make sure that the following changes have been applied in transfer objects:
TRANSFER | TYPE | EVENT | PATH |
---|---|---|---|
RestAbstractProductAvailabilityAttributesTransfer | class | created | src/Generated/Shared/Transfer/RestAbstractProductAvailabilityAttributesTransfer |
RestConcreteProductAvailabilityAttributesTransfer | class | created | src/Generated/Shared/Transfer/RestConcreteProductAvailabilityAttributesTransfer |
3) Enable resources and relationships
Activate the following plugins:
PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
---|---|---|---|
AbstractProductAvailabilitiesRoutePlugin | Registers the abstract product availabilities resource. | None | Spryker\Glue\ProductAvailabilitiesRestApi\Plugin |
ConcreteProductAvailabilitiesRoutePlugin | Registers the concrete product availabilities resource. | None | Spryker\Glue\ProductAvailabilitiesRestApi\Plugin |
AbstractProductAvailabilitiesByResourceIdResourceRelationshipPlugin | Adds the abstract product availability resource as a relationship to the abstract product resource. | None | Spryker\Glue\ProductAvailabilitiesRestApi\Plugin\GlueApplication |
ConcreteProductAvailabilitiesByResourceIdResourceRelationshipPlugin | Adds the concrete product availability resource as a relationship to the concrete product resource. | None | Spryker\Glue\ProductAvailabilitiesRestApi\Plugin\GlueApplication |
src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php
<?php
namespace Pyz\Glue\GlueApplication;
use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
use Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface;
use Spryker\Glue\ProductAvailabilitiesRestApi\Plugin\AbstractProductAvailabilitiesRoutePlugin;
use Spryker\Glue\ProductAvailabilitiesRestApi\Plugin\ConcreteProductAvailabilitiesRoutePlugin;
use Spryker\Glue\ProductAvailabilitiesRestApi\Plugin\GlueApplication\AbstractProductAvailabilitiesByResourceIdResourceRelationshipPlugin;
use Spryker\Glue\ProductAvailabilitiesRestApi\Plugin\GlueApplication\ConcreteProductAvailabilitiesByResourceIdResourceRelationshipPlugin;
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig;
class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
/**
* @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
*/
protected function getResourceRoutePlugins(): array
{
return [
new AbstractProductAvailabilitiesRoutePlugin(),
new ConcreteProductAvailabilitiesRoutePlugin(),
];
}
/**
* @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 AbstractProductAvailabilitiesByResourceIdResourceRelationshipPlugin()
);
$resourceRelationshipCollection->addRelationship(
ProductsRestApiConfig::RESOURCE_CONCRETE_PRODUCTS,
new ConcreteProductAvailabilitiesByResourceIdResourceRelationshipPlugin()
);
return $resourceRelationshipCollection;
}
}
Make sure that the following endpoints are available:
http://mysprykershop.com/abstract-products/{{abstract_sku}}/abstract-product-availabilities
http://mysprykershop.com/concrete-products/{{concrete_sku}}/concrete-product-availabilities
Send the GET http://mysprykershop.com/abstract-products/{{abstract_sku}}?include=abstract-product-availabilities
and make sure that the response includes relationships to the abstract-product-availabilities
resource.
Send the GET http://mysprykershop.com/concrete-products/{{concrete_sku}}?include=concrete-product-availabilities
and make sure that the response includes relationships to the concrete-product-availabilities
resource.
Thank you!
For submitting the form