Migrate CatalogSearchRestApi to API Platform
Edit on GitHubThis document describes how to migrate the CatalogSearchRestApi Glue module to the API Platform Catalog module.
Prerequisites
Complete the cross-cutting changes described in Migrate Glue REST API to API Platform before proceeding.
Overview
The CatalogSearchRestApi module provided the following storefront endpoints:
| Endpoint | Operation | Old plugin |
|---|---|---|
GET /catalog-search |
Full-text product search | CatalogSearchResourceRoutePlugin |
GET /catalog-search-suggestions |
Search suggestions | CatalogSearchSuggestionsResourceRoutePlugin |
These are now served by the API Platform Catalog module.
1. Update module dependencies
composer require spryker/catalog:"^X.Y.Z"
Version
Use the version that includes the API Platform resources. Check the module changelog for the exact version.
2. Remove route plugins and validator from GlueApplicationDependencyProvider
In src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php, remove the following from getResourceRoutePlugins() and getRestRequestValidatorPlugins():
| Plugin to remove | Method | Fully qualified class name |
|---|---|---|
CatalogSearchResourceRoutePlugin |
getResourceRoutePlugins() |
Spryker\Glue\CatalogSearchRestApi\Plugin\CatalogSearchResourceRoutePlugin |
CatalogSearchSuggestionsResourceRoutePlugin |
getResourceRoutePlugins() |
Spryker\Glue\CatalogSearchRestApi\Plugin\CatalogSearchSuggestionsResourceRoutePlugin |
CatalogSearchRequestParametersIntegerRestRequestValidatorPlugin |
getRestRequestValidatorPlugins() |
Spryker\Glue\CatalogSearchRestApi\Plugin\CatalogSearchRequestParametersIntegerRestRequestValidatorPlugin |
3. Remove relationship plugins for catalog-search resources
In the getResourceRelationshipPlugins() method, remove the following relationship registrations:
| Resource constant | Plugin to remove | Fully qualified class name |
|---|---|---|
CatalogSearchRestApiConfig::RESOURCE_CATALOG_SEARCH |
CatalogSearchAbstractProductsResourceRelationshipPlugin |
Spryker\Glue\CatalogSearchProductsResourceRelationship\Plugin\CatalogSearchAbstractProductsResourceRelationshipPlugin |
CatalogSearchRestApiConfig::RESOURCE_CATALOG_SEARCH_SUGGESTIONS |
CatalogSearchSuggestionsAbstractProductsResourceRelationshipPlugin |
Spryker\Glue\CatalogSearchProductsResourceRelationship\Plugin\CatalogSearchSuggestionsAbstractProductsResourceRelationshipPlugin |
4. Regenerate transfers and API resources
docker/sdk cli console transfer:generate
docker/sdk cli glue api:generate
docker/sdk cli glue cache:clear
Relationship plugin status
| Plugin | Status | Notes |
|---|---|---|
CatalogSearchAbstractProductsResourceRelationshipPlugin |
Removed | API Platform handles product relationships via the ?include= query parameter. |
CatalogSearchSuggestionsAbstractProductsResourceRelationshipPlugin |
Removed | Same as above. |
Thank you!
For submitting the form