Install the Merchant Category Glue API
Edit on GitHubThis document describes how to integrate the Merchant Category Glue API feature into a Spryker project.
Install feature core
Follow the steps below to install the Merchant Category Glue API feature core.
Prerequisites
Install the required features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Spryker Core | 202311.0 | Install the Spryker Core feature |
Marketplace Merchant Category | 202311.0 | Install the Marketplace Merchant Category feature |
1) Install the required modules
Install the required modules using Composer:
composer require spryker/merchant-categories-rest-api:"^1.0.0" --update-with-dependencies
Make sure that the following modules have been installed:
MODULE | EXPECTED DIRECTORY |
---|---|
MerchantCategoriesRestApi | vendor/spryker/merchant-categories-rest-api |
2) Set up transfer objects
Generate transfer changes:
console transfer:generate
Make sure the following changes have been applied in transfer objects:
TRANSFER | TYPE | EVENT | PATH |
---|---|---|---|
RestMerchantsAttributes | object | Created | src/Generated/Shared/Transfer/RestMerchantsAttributes |
3) Enable resources and relationships
Activate the following plugins:
PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
---|---|---|---|
MerchantCategoryMerchantRestAttributesMapperPlugin | Maps active categories from MerchantStorageTransfer to RestMerchantsAttributesTransfer . |
Spryker\Glue\MerchantCategoriesRestApi\Plugin\MerchantsRestApi |
src/Pyz/Glue/MerchantsRestApi/MerchantsRestApiDependencyProvider.php
<?php
namespace Pyz\Glue\MerchantsRestApi;
use Spryker\Glue\MerchantCategoriesRestApi\Plugin\MerchantsRestApi\MerchantCategoryMerchantRestAttributesMapperPlugin;
use Spryker\Glue\MerchantsRestApi\MerchantsRestApiDependencyProvider as SprykerMerchantsRestApiDependencyProvider;
class MerchantsRestApiDependencyProvider extends SprykerMerchantsRestApiDependencyProvider
{
/**
* @return array<\Spryker\Glue\MerchantsRestApiExtension\Dependency\Plugin\MerchantRestAttributesMapperPluginInterface>
*/
public function getMerchantRestAttributesMapperPlugins(): array
{
return [
new MerchantCategoryMerchantRestAttributesMapperPlugin(),
];
}
}
Make sure that when you send the request GET https://glue.mysprykershop.com/merchants
, you can see the category keys and names for merchants assigned to categories.
Make sure that when you send the request GET https://glue.mysprykershop.com/merchants?category-keys[]={{some-category-key}}
, you can see only merchants that belong to the particular category in the response.
Thank you!
For submitting the form