Glue API Navigation feature integration
Edit on GitHubInstall feature API
Prerequisites
To start feature integration, review and install the necessary features: |Name|Version| |—|—| |Spryker Core|201903.0| |Navigation|201903.0|
1) Install the required modules using Composer
Run the following command to install the required modules:
composer require spryker/navigations-rest-api:"^1.0.0" --update-with-dependencies
Verification
Make sure that the following module is installed:
Run the following commands to generate transfer changes:
console transfer:generate
Verification
Make sure that the following changes are present in the transfer objects:
3) Set up Configuration
Configure mapping to specify source field from which resourceId field should be filled depends on navigation node type.
src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php
<?php
namespace Pyz\Glue\NavigationsRestApi;
use Spryker\Glue\NavigationsRestApi\NavigationsRestApiConfig as SprykerNavigationsRestApiConfigi;
class NavigationsRestApiConfig extends SprykerNavigationsRestApiConfig
{
/**
* @return array
*/
public function getNavigationTypeToUrlResourceIdFieldMapping(): array
{
return [
'category' => 'fkResourceCategorynode',
'cms_page' => 'fkResourcePage',
];
}
}
4) Set up Behavior
Enable Resources and Relationships
Activate the following plugin:
|Plugin|Specification|Prerequisites|Namespace|
|—|—|—|—|
|NavigationsResourceRoutePlugin
|Registers the navigations resource.|None|Spryker\Glue\NavigationsRestApi\Plugin\ResourceRoute
|
src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php
<;?php
namespace Pyz\Glue\GlueApplication;
use Spryker\Glue\CategoriesRestApi\Plugin\CategoriesResourceRoutePlugin;
use Spryker\Glue\CategoriesRestApi\Plugin\CategoryResourceRoutePlugin;
use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
/**
* @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
*/
protected function getResourceRoutePlugins(): array
{
return [
new NavigationsResourceRoutePlugin(),
];
}
}
Verification
Make sure that the following endpoint is available:http://mysprykershop.com/navigations/`{navigationId}`
Thank you!
For submitting the form