Glue API - Price feature integration

Edit on GitHub

Install feature API

Prerequisites

To start feature integration, overview and install the necessary features:

Name Version Integration guide
Glue API: Glue Application 201903.0 Glue Application feature integration
Product 201903.0 Products feature integration
Price 201903.0

1) Install the required modules using Composer

Run the following command to install the required modules: composer require spryker/product-prices-rest-api:"^1.1.0" spryker/products-product-prices-resource-relationship:"^1.0.0" --update-with-dependencies

“Verification”

Make sure that the following modules are installed:

ModuleExpected Directory
ProductPricesRestApivendor/spryker/product-prices-rest-api
ProductsProductPricesResourceRelationshipvendor/spryker/products-product-prices-resource-relationship

2) Set up Transfer Objects

Run the following commands to generate transfer changes: console transfer:generate

“Verification”

Make sure that the following changes are present in the transfer objects:

TransferTypeEventPath
RestProductPriceAttributesTransferclasscreatedsrc/Generated/Shared/Transfer/RestProductPriceAttributesTransfer
RestProductPricesAttributesTransferclasscreatedsrc/Generated/Shared/Transfer/RestProductPricesAttributesTransfer
RestCurrencyTransferclasscreatedsrc/Generated/Shared/Transfer/RestCurrencyTransfer

3) Set up Behavior

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 product resource. None Spryker\Glue\ProductsProductPricesResourceRelationship\Plugin
ConcreteProductsProductPricesResourceRelationshipPlugin Adds the concrete product prices resource as a relationship to the concrete product resource. None Spryker\Glue\ProductsProductPricesResourceRelationship\Plugin
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;
    }
}

“Verification”

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 a request to http://mysprykershop.com/abstract-products/{{abstract_sku}}?include=abstract-product-prices. Make sure that the response includes relationships to the abstract-product-prices resources.
Send a request to http://mysprykershop.com/concrete-products/{{concrete_sku}}?include=concrete-product-prices. Make sure that the response includes relationships to the concrete-product-prices resources.

Last review date: Apr 25, 2019