Migrate SharedCartsRestApi to API Platform

Edit on GitHub

This document describes how to migrate the SharedCartsRestApi Glue module to the API Platform SharedCart module.

Prerequisites

Complete the cross-cutting changes described in Migrate Glue REST API to API Platform before proceeding.

Migrating this module requires Migrate CartsRestApi to be completed first.

Overview

The SharedCartsRestApi module provided the following storefront endpoint:

Endpoint Operation Old plugin
GET /shared-carts List shared carts SharedCartsResourceRoutePlugin
GET /shared-carts/{id} Get shared cart SharedCartsResourceRoutePlugin
POST /shared-carts Share a cart SharedCartsResourceRoutePlugin
PATCH /shared-carts/{id} Update shared cart SharedCartsResourceRoutePlugin
DELETE /shared-carts/{id} Delete shared cart SharedCartsResourceRoutePlugin

These are now served by the API Platform SharedCart module.

1. Update module dependencies

composer require spryker/shared-cart:"^X.Y.Z"
Version

Use the version that includes the API Platform resources. Check the module changelog for the exact version.

2. Remove route plugin from GlueApplicationDependencyProvider

In src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php, remove the following plugin from getResourceRoutePlugins():

Plugin to remove Fully qualified class name
SharedCartsResourceRoutePlugin Spryker\Glue\SharedCartsRestApi\Plugin\GlueApplication\SharedCartsResourceRoutePlugin

3. Delete the obsolete Pyz SharedCartsRestApi module

Delete src/Pyz/Glue/SharedCartsRestApi/SharedCartsRestApiDependencyProvider.php. This file registered CompanyUserStorageProviderPlugin for the legacy SharedCartsRestApi. The API Platform SharedCart module handles company user resolution natively.

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 Registered on resource Status Notes
SharedCartByCartIdResourceRelationshipPlugin carts Removed Shared cart data is now included in the Cart resource via the API Platform SharedCart module.
CartPermissionGroupByShareDetailResourceRelationshipPlugin shared-carts Remains This plugin is still registered on shared-carts in the legacy Glue layer. The cart-permission-groups endpoint is still served by CartPermissionGroupsRestApi. Do not remove until CartPermissionGroupsRestApi is migrated.
CompanyUserByShareDetailResourceRelationshipPlugin shared-carts Remains Same reasoning as above. Do not remove yet.