Glue API - Product Tax Sets feature integration

Edit on GitHub

Install feature API

Prerequisites

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

Name Version
Spryker Core 2018.12.0
Product Management 2018.12.0
Tax 2018.12.0
ProductsRestApi 2.2.3

1) Install the required modules using Composer

Run the following commands to install the required modules:

composer require spryker/product-tax-sets-rest-api:"^1.0.6" --update-with-dependencies
composer require spryker/products-product-tax-sets-resource-relationship:"^1.0.0" --update-with-dependencies 
“Verification”

Make sure that the following modules have been installed:

Module Expected Directory
ProductTaxSetsRestApi vendor/spryker/product-tax-sets-rest-api
ProductsProductTaxSetsResourceRelationship vendor/spryker/products-product-tax-sets-resource-relationship

2) Set up Database Schema and Transfer Objects

Run the following commands to apply database changes and generate entity and transfer changes:

console transfer:generate
console propel:install
console transfer:generate 
Make sure that the following changes are present by checking your database:
Database entity Type Event
spy_tax_set.uuid column added
Make sure that the following changes are present in the transfer objects:
Transfer Type Event Path
RestProductTaxRateTransfer class created src/Generated/Shared/Transfer/RestProductTaxRateTransfer
RestProductTaxSetsAttributesTransfer class created src/Generated/Shared/Transfer/RestProductTaxSetsAttributesTransfer
TaxSetTransfer.uuid property added src/Generated/Shared/Transfer/TaxSetTransfer

3) Set up Behavior

Generate UUIDs for the existing spy_tax_set records without UUID:

Run the following command:

console tax-sets:uuid:update 
Make sure that the UUID field is filled out for all the records in the `spy_tax_set` table. You can run the following SQL query to make sure the result equals to 0 records:
select count(*) from spy_tax_set where uuid is NULL; 

Enable resource and relationship

Activate the following plugins:

Plugin Specification Prerequisites Namespace
ProductTaxSetsResourceRoutePlugin Registers the product tax resource. None Spryker\Glue\ProductTaxSetsRestApi\Plugin
ProductsProductTaxSetsResourceRelationshipPlugin Adds the product tax sets resource as a relationship to an abstract product resource. None Spryker\Glue\ProductsProductTaxSetsResourceRelationship\Plugin
src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php
<?php

namespace Pyz\Glue\GlueApplication;

use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
use Spryker\Glue\ProductTaxSetsRestApi\Plugin\ProductTaxSetsResourceRoutePlugin;
use Spryker\Glue\ProductsProductTaxSetsResourceRelationship\Plugin\ProductsProductTaxSetsResourceRelationshipPlugin;
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig;

class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
   /**
    * @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
    */
   protected function getResourceRoutePlugins(): array
   {
       return [
           new ProductTaxSetsResourceRoutePlugin(),
       ];
   }

   /**
   * @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 ProductsProductTaxSetsResourceRelationshipPlugin()
       );

       return $resourceRelationshipCollection;
   }
}

“Verification”

Make sure that the following endpoint is available: http://mysprykershop.comop.com//abstract-products/{{abstract_sku}}/product-tax-sets

“Verification”

Send a request to http://mysprykershop.comop.com//abstract-products/{{abstract_sku}}?include=product-tax-sets. Make sure that the response includes relationships to the product-tax-sets resources.