Glue API - Catalog Search feature integration
Edit on GitHubInstall feature API
Prerequisites
To start feature integration, overview and install the necessary features: |Name|Version|Integration guide| |—|—|—| |Spryker Core|201903.0|Glue Application feature integration | |Search|201903.0|| |Catalog|201903.0|| |Product|201903.0|Product API feature integration | |Catalog + Price|201903.0||
1) Install the required modules using Composer
Run the following command to install the required modules:
composer require spryker/catalog-search-rest-api:"^2.1.0" spryker/catalog-search-products-resource-relationship:"^1.1.0" --update-with-dependencies
2) Set up Transfer objects
Run the following command to generate transfer changes:
console transfer:generate
3) Set Up Behavior
Enable resources and relationships
Activate the following plugins:
|Plugin|Specification|Prerequisites|Namespace|
|— |— |— |— |
|CatalogSearchAbstractProductsResourceRelationshipPlugin
|Adds the abstract-products
resource relationship to search results.|None|Spryker\Glue\CatalogSearchProductsResourceRelationship\Plugin
|
|CatalogSearchSuggestionsAbstractProductsResourceRelationshipPlugin
|Adds the abstract-products
resource relationship to search suggestions results.|None|Spryker\Glue\CatalogSearchProductsResourceRelationship\Plugin
|
|CatalogSearchResourceRoutePlugin
|Registers the search
resource.|None|Spryker\Glue\CatalogSearchRestApi\Plugin
|
|CatalogSearchSuggestionsResourceRoutePlugin
|Registers the search-suggestions
resource.|None|Spryker\Glue\CatalogSearchRestApi\Plugin
|
src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php
<?php
namespace Pyz\Glue\GlueApplication;
use Spryker\Glue\CatalogSearchProductsResourceRelationship\Plugin\CatalogSearchAbstractProductsResourceRelationshipPlugin;
use Spryker\Glue\CatalogSearchProductsResourceRelationship\Plugin\CatalogSearchSuggestionsAbstractProductsResourceRelationshipPlugin;
use Spryker\Glue\CatalogSearchRestApi\CatalogSearchRestApiConfig;
use Spryker\Glue\CatalogSearchRestApi\Plugin\CatalogSearchResourceRoutePlugin;
use Spryker\Glue\CatalogSearchRestApi\Plugin\CatalogSearchSuggestionsResourceRoutePlugin;
use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
/**
* @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
*/
protected function getResourceRoutePlugins(): array
{
return [
new CatalogSearchResourceRoutePlugin(),
new CatalogSearchSuggestionsResourceRoutePlugin(),
];
}
/**
* @param \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface $resourceRelationshipCollection
*
* @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface
*/
protected function getResourceRelationshipPlugins(
ResourceRelationshipCollectionInterface $resourceRelationshipCollection
): ResourceRelationshipCollectionInterface {
$resourceRelationshipCollection->addRelationship(
CatalogSearchRestApiConfig::RESOURCE_CATALOG_SEARCH,
new CatalogSearchAbstractProductsResourceRelationshipPlugin()
);
$resourceRelationshipCollection->addRelationship(
CatalogSearchRestApiConfig::RESOURCE_CATALOG_SEARCH_SUGGESTIONS,
new CatalogSearchSuggestionsAbstractProductsResourceRelationshipPlugin()
);
return $resourceRelationshipCollection;
}
}
Verification
- https://glue.mysprykershop.com/catalog-search?q={{q_term}}
- https://glue.mysprykershop.com/catalog-search-suggestions?q={{q_term}}
Thank you!
For submitting the form