Install the Tax Glue API

Edit on GitHub

Install feature API

Prerequisites

Install the required features:

Name Version INSTALLATION GUIDE
Spryker Core 201907.0 Glue Application
Product 201907.0 Products API
Tax 201907.0

1) Install the required modules

Install the required modules using Composer:

composer require spryker/product-tax-sets-rest-api:"^2.0.0" --update-with-dependencies

Make sure that the following module has been installed:

Module Expected Directory
ProductTaxSetsRestApi vendor/spryker/product-tax-sets-rest-api

2) Set up database schema and transfer objects

Apply database changes and generate entity and transfer changes:

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

3) Set up Behavior

Generate UUIDs for existing records

Run the following command:

console uuid:generate Tex spy_tax_set
“Verification”

Make sure that the uuid field is populated for all records in the spy_tax_set table. You can run the following SQL query for it and make sure that the result is 0 records.
`SELECT COUNT(*

FROM spy_tax_set WHERE uuid IS NULL;`)

Enable resource and relationship

Activate the following plugin:

Plugin Specification Prerequisites Namespace
ProductTaxSetsResourceRoutePlugin Registers the product-tax resource. None Spryker\Glue\ProductTaxSetsRestApi\Plugin\GlueApplication
ProductTaxSetByProductAbstractSkuResourceRelationshipPlugin Adds the product-tax-sets resource as a relationship to the abstract-product resource. None Spryker\Glue\ProductTaxSetsRestApi\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\ProductsRestApi\ProductsRestApiConfig;
use Spryker\Glue\ProductTaxSetsRestApi\Plugin\GlueApplication\ProductTaxSetByProductAbstractSkuResourceRelationshipPlugin;
use Spryker\Glue\ProductTaxSetsRestApi\Plugin\GlueApplication\ProductTaxSetsResourceRoutePlugin;

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 ProductTaxSetByProductAbstractSkuResourceRelationshipPlugin()
		);

		return $resourceRelationshipCollection;
	}
}

“Verification”

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

See also:

  Last review date: Mar 21, 2019