Install the Product Bundles Glue API
Edit on GitHubFollow the steps below to integrate the Glue API: Product Bundles feature.
Prerequisites
To start the feature integration, overview and install the necessary features:
| NAME | VERSION | INSTALLATION GUIDE |
|---|---|---|
| Spryker Core | 202507.0 | Install the Spryker Core Glue API |
| Product Bundles | 202507.0 | Install the Product Bundles feature |
| Order Management | 202507.0 | Install the Order Management Glue API |
1) Install the required modules
Install the required modules using Composer:
composer require spryker/product-bundles-rest-api:"^1.0.0" --update-with-dependencies
Make sure that the following module has been installed:
| MODULE | EXPECTED DIRECTORY |
|---|---|
| ProductBundlesRestApi | vendor/spryker/product-bundles-rest-api |
2) Set up transfer objects
Set up transfer objects:
console transfer:generate
Make sure that the following changes have been applied in the transfer objects:
| TRANSFER | TYPE | EVENT | PATH |
|---|---|---|---|
| RestBundledProductsAttributesTransfer | class | created | src/Generated/Shared/Transfer/RestBundledProductsAttributesTransfer |
| RestErrorMessageTransfer | class | created | src/Generated/Shared/Transfer/RestErrorMessageTransfer |
| ProductBundleStorageTransfer | class | created | src/Generated/Shared/Transfer/ProductBundleStorageTransfer |
| ProductForProductBundleStorageTransfer | class | created | src/Generated/Shared/Transfer/ProductForProductBundleStorageTransfer |
| OrderTransfer | class | created | src/Generated/Shared/Transfer/OrderTransfer |
| ItemTransfer | class | created | src/Generated/Shared/Transfer/ItemTransfer |
| RestOrderDetailsAttributesTransfer | class | created | src/Generated/Shared/Transfer/RestOrderDetailsAttributesTransfer |
| RestOrderItemsAttributesTransfer | class | created | src/Generated/Shared/Transfer/RestOrderItemsAttributesTransfer |
| RestOrderItemMetadataTransfer | class | created | src/Generated/Shared/Transfer/RestOrderItemMetadataTransfer |
| ProductBundleStorageCriteriaTransfer | class | created | src/Generated/Shared/Transfer/ProductBundleStorageCriteriaTransfer |
3) Set up behavior
Activate the following plugins:
| PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
|---|---|---|---|
| BundledProductByProductConcreteSkuResourceRelationshipPlugin | Adds the bundled-products resource as a relationship to the concrete-products resource by product concrete sku. |
None | Spryker\Glue\ProductBundlesRestApi\Plugin\GlueApplication |
| ConcreteProductsBundledProductsResourceRoutePlugin | Provides the bundled-products resource route with concrete-products as a parent resource. |
None | Spryker\Glue\ProductBundlesRestApi\Plugin\GlueApplication |
| BundleItemRestOrderDetailsAttributesMapperPlugin | Maps the additional information fromOrderTransfer to RestOrderDetailsAttributesTransfer. |
None | Spryker\Glue\ProductBundlesRestApi\Plugin\OrdersRestApi |
src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php
<?php
namespace Pyz\Glue\GlueApplication;
use Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface;
use Spryker\Glue\ProductBundlesRestApi\Plugin\GlueApplication\BundledProductByProductConcreteSkuResourceRelationshipPlugin;
use Spryker\Glue\ProductBundlesRestApi\Plugin\GlueApplication\ConcreteProductsBundledProductsResourceRoutePlugin;
use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
use Spryker\Glue\ProductBundlesRestApi\ProductBundlesRestApiConfig;
use Spryker\Glue\ProductsRestApi\Plugin\GlueApplication\ConcreteProductBySkuResourceRelationshipPlugin;
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig;
class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
/**
* @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
*/
protected function getResourceRoutePlugins(): array
{
return [
new ConcreteProductsBundledProductsResourceRoutePlugin(),
];
}
/**
* @param \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface $resourceRelationshipCollection
*
* @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface
*/
protected function getResourceRelationshipPlugins(
ResourceRelationshipCollectionInterface $resourceRelationshipCollection
): ResourceRelationshipCollectionInterface {
$resourceRelationshipCollection->addRelationship(
ProductBundlesRestApiConfig::RESOURCE_BUNDLED_PRODUCTS,
new ConcreteProductBySkuResourceRelationshipPlugin()
);
$resourceRelationshipCollection->addRelationship(
ProductsRestApiConfig::RESOURCE_CONCRETE_PRODUCTS,
new BundledProductByProductConcreteSkuResourceRelationshipPlugin()
);
return $resourceRelationshipCollection;
}
}
Ensure that you have activated the plugins:
| REQUEST | TEST |
|---|---|
GET https://glue.mysprykershop.com/bundled-products |
Returns the list of bundled products. |
GET https://glue.mysprykershop.com/concrete-products/{{sku}}/bundled-products?include=concrete-products |
In the response body, the bundled-products resource has a relationship to the concrete-products resource. |
GET https://glue.mysprykershop.com/concrete-products/{{sku}}?include=bundled-products |
In the response body, the concrete-products resource has a relationship to its bundled-products resource. |
src/Pyz/Glue/OrdersRestApi/OrdersRestApiDependencyProvider.php
<?php
namespace Pyz\Glue\OrdersRestApi;
use Spryker\Glue\ProductBundlesRestApi\Plugin\OrdersRestApi\BundleItemRestOrderDetailsAttributesMapperPlugin;
use Spryker\Glue\AuthRestApi\AuthRestApiDependencyProvider as SprykerAuthRestApiDependencyProvider;
class OrdersRestApiDependencyProvider extends SprykerOrdersRestApiDependencyProvider
{
/**
* @return \Spryker\Glue\OrdersRestApiExtension\Dependency\Plugin\RestOrderDetailsAttributesMapperPluginInterface[]
*/
protected function getRestOrderDetailsAttributesMapperPlugins(): array
{
return [
new BundleItemRestOrderDetailsAttributesMapperPlugin(),
];
}
}
Ensure that you have activated the plugins:
-
Place an order with product bundles.
-
Send the request:
GET https://glue.mysprykershop.com/orders/{{orderReference}}. -
Check that, in the response:
-
There is a
data.attributes.bundleItemssection. -
The
data.attributes.items.relatedBundleItemIdentifierattribute value of a bundled item is the same as thedata.attributes.bundleItems.bundleItemIdentifierattribute value of the product bundle item it belongs to.
-
Install related features
Integrate the following related features:
| FEATURE | REQUIRED FOR THE CURRENT FEATURE | INSTALLATION GUIDE |
|---|---|---|
| Products | ✓ | Install the Product Glue API - ongoing |
Thank you!
For submitting the form