Install the Product Price Glue API
Edit on GitHubThis document describes how to install the Prices feature API.
Prerequisites
To start feature integration, overview, and install the necessary features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Spryker Core | 202311.0 | Install the Spryker Core Glue API |
Product | 202311.0 | Install the Product Glue API - ongoing |
Price | 202311.0 | Install the Prices feature - ongoing |
1) Install the required modules
Install the required modules using Composer:
composer require spryker/product-prices-rest-api:"^1.1.0" spryker/products-product-prices-resource-relationship:"^1.0.0" spryker/price-product-volumes-rest-api:"^1.0.0" --update-with-dependencies
Make sure that the following modules have been installed:
MODULE | EXPECTED DIRECTORY |
---|---|
ProductPricesRestApi | vendor/spryker/product-prices-rest-api |
ProductsProductPricesResourceRelationship | vendor/spryker/products-product-prices-resource-relationship |
PriceProductVolumesRestApi | vendor/spryker/price-product-volume-rest-api |
2) Set up transfer objects
Generate transfer changes:
console transfer:generate
Make sure that the following changes exist in transfer objects:
TRANSFER | TYPE | EVENT | PATH |
---|---|---|---|
RestProductPriceAttributesTransfer | class | created | src/Generated/Shared/Transfer/RestProductPriceAttributesTransfer.php |
RestProductPricesAttributesTransfer | class | created | src/Generated/Shared/Transfer/RestProductPricesAttributesTransfer.php |
RestCurrencyTransfer | class | created | src/Generated/Shared/Transfer/RestCurrencyTransfer.php |
RestProductPriceVolumesAttributesTransfer | class | created | src/Generated/Shared/Transfer/RestProductPriceVolumesAttributesTransfer.php |
RestProductPriceAttributesTransfer.volumePrices | property | added | src/Generated/Shared/Transfer/RestProductPriceAttributesTransfer.php |
3) Enable resources and relationships
Activate the following plugins:
PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
---|---|---|---|
AbstractProductPricesRoutePlugin | Registers the abstract-product-prices resource. |
None | Spryker\Glue\ProductPricesRestApi\Plugin |
ConcreteProductPricesRoutePlugin | Registers the concrete-product-prices resource. |
None | Spryker\Glue\ProductPricesRestApi\Plugin |
AbstractProductsProductPricesResourceRelationshipPlugin | Adds the abstract-product-prices resource as a relationship to the abstract-products resource. |
None | Spryker\Glue\ProductsProductPricesResourceRelationship\Plugin |
ConcreteProductsProductPricesResourceRelationshipPlugin | Adds the concrete-product-prices resource as a relationship to the concrete-products resource. |
None | Spryker\Glue\ProductsProductPricesResourceRelationship\Plugin |
PriceProductVolumeRestProductPricesAttributesMapperPlugin | Adds volume price data to abstract-product-prices and concrete-product-prices resources. |
None | Spryker\Glue\PriceProductVolumesRestApi\Plugin\ProductPriceRestApi |
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\ProductPricesRestApi\Plugin\AbstractProductPricesRoutePlugin;
use Spryker\Glue\ProductPricesRestApi\Plugin\ConcreteProductPricesRoutePlugin;
use Spryker\Glue\ProductsProductPricesResourceRelationship\Plugin\AbstractProductsProductPricesResourceRelationshipPlugin;
use Spryker\Glue\ProductsProductPricesResourceRelationship\Plugin\ConcreteProductsProductPricesResourceRelationshipPlugin;
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig;
class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
/**
* @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
*/
protected function getResourceRoutePlugins(): array
{
return [
new AbstractProductPricesRoutePlugin(),
new ConcreteProductPricesRoutePlugin(),
];
}
/**
* @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 AbstractProductsProductPricesResourceRelationshipPlugin()
);
$resourceRelationshipCollection->addRelationship(
ProductsRestApiConfig::RESOURCE_CONCRETE_PRODUCTS,
new ConcreteProductsProductPricesResourceRelationshipPlugin()
);
return $resourceRelationshipCollection;
}
}
-
Make sure that the following endpoints are available:
-
http://mysprykershop.com/abstract-products/{{abstract_sku}}/abstract-product-prices
-
http://mysprykershop.com/concrete-products/{{concrete_sku}}/concrete-product-prices
-
-
Send the
GET http://mysprykershop.com/abstract-products/{{abstract_sku}}?include=abstract-product-prices
request. Make sure that the response contains relationships to theabstract-product-prices
resources. -
Send the
GET http://mysprykershop.com/concrete-products/{{concrete_sku}}?include=concrete-product-prices
request. Make sure that the response contains relationships to theconcrete-product-prices
resources.
src/Pyz/Glue/ProductPricesRestApi/ProductPricesRestApiDependencyProvider.php
<?php
namespace Pyz\Glue\ProductPricesRestApi;
use Spryker\Glue\PriceProductVolumesRestApi\Plugin\ProductPriceRestApi\PriceProductVolumeRestProductPricesAttributesMapperPlugin;
use Spryker\Glue\ProductPricesRestApi\ProductPricesRestApiDependencyProvider as SprykerProductPricesRestApiDependencyProvider;
class ProductPricesRestApiDependencyProvider extends SprykerProductPricesRestApiDependencyProvider
{
/**
* @return \Spryker\Glue\ProductPricesRestApiExtension\Dependency\Plugin\RestProductPricesAttributesMapperPluginInterface[]
*/
protected function getRestProductPricesAttributesMapperPlugins(): array
{
return [
new PriceProductVolumeRestProductPricesAttributesMapperPlugin(),
];
}
}
To verify that you’ve activated PriceProductVolumeRestProductPricesAttributesMapperPlugin
:
- Create an abstract product with a volume price.
- Send the request
GET https://glue.mysprykershop.com/abstract-products/{{sku}}/abstract-product-prices
request and make sure that the response contains volume prices data.
Thank you!
For submitting the form