Integrate the Wishlist Glue API

Edit on GitHub

Follow the steps below to install Wishlist feature API.

Prerequisites

Install the required features:

NAME VERSION INTEGRATION GUIDE
Spryker Core 202311.0 Glue Application feature integration
Product 202311.0 Product API feature integration
Wishlist 202311.0

1) Install the required modules

Run the following command to install the required modules:

composer require spryker/wishlists-rest-api:"^1.0.0" --update-with-dependencies
“Verification”

Make sure that the following module has been installed:

MODULE EXPECTED DIRECTORY
WishlistsRestApi vendor/spryker/wishlists-rest-apiWishlistItems

2) Set up database schema and transfer objects

Run the following commands to apply database changes, and generate entity and transfer changes:

console propel:install
console transfer:generate
“Verification”

Make sure that the following changes have occurred in the database:

DATABASE ENTITY TYPE EVENT
spy_wishlist.uuid column added
“Verification”

Make sure that the following changes have occurred in transfer objects:

TRANSFER TYPE EVENT PATH
RestWishlistItemsAttributesTransfer class created src/Generated/Shared/Transfer/RestWishlistItemsAttributesTransfer
RestWishlistsAttributesTransfer class created src/Generated/Shared/Transfer/RestWishlistsAttributesTransfer
WishlistTransfer.uuid property added src/Generated/Shared/Transfer/WishlistTransfer

3) Set up behavior

Migrate data in the database

The following steps generate UUIDs for existing entities in the spy_wishlist table.

Run the following command:

console uuid:update Wishlist spy_wishlist
“Verification”

Make sure that the uuid field is populated for all records in the spy_wishlist table. For this purpose, run the following SQL query and make sure that the result is 0 records: SELECT COUNT(*) FROM spy_wishlist WHERE uuid IS NULL;

Enable resources and relationships

Activate the following plugins:

PLUGIN SPECIFICATION PREREQUISITES NAMESPACE
WishlistsResourceRoutePlugin Registers the wishlists resource. None Spryker\Glue\WishlistsRestApi\Plugin
WishlistItemsResourceRoutePlugin Registers the wishlist-items resource. None Spryker\Glue\WishlistsRestApi\Plugin
WishlistRelationshipByResourceIdPlugin Adds the wishlists resource as a relationship to the customers resource. None Spryker\Glue\WishlistsRestApi\Plugin
ConcreteProductBySkuResourceRelationshipPlugin Adds the concrete-products resource as a relationship to the wishlist-items resource. None Spryker\Glue\ProductsRestApi\Plugin\GlueApplication

src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php

<?php

namespace Pyz\Glue\GlueApplication;

use Spryker\Glue\CustomersRestApi\CustomersRestApiConfig;
use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
use Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface;
use Spryker\Glue\WishlistsRestApi\Plugin\WishlistItemsResourceRoutePlugin;
use Spryker\Glue\WishlistsRestApi\Plugin\WishlistRelationshipByResourceIdPlugin;
use Spryker\Glue\WishlistsRestApi\Plugin\WishlistsResourceRoutePlugin

class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
    /**
     * @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRoutePluginInterface[]
     */
    protected function getResourceRoutePlugins(): array
    {
        return [
            new WishlistsResourceRoutePlugin(),
            new WishlistItemsResourceRoutePlugin(),
        ];
    }

    /**
     * @param \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface $resourceRelationshipCollection
     *
     * @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\ResourceRelationshipCollectionInterface
     */
    protected function getResourceRelationshipPlugins(
        ResourceRelationshipCollectionInterface $resourceRelationshipCollection
    ): ResourceRelationshipCollectionInterface {
        $resourceRelationshipCollection->addRelationship(
            CustomersRestApiConfig::RESOURCE_CUSTOMERS,
            new WishlistRelationshipByResourceIdPlugin()
        );

        return $resourceRelationshipCollection;
    }
}
“Verification”

Make sure that the following endpoints are available: http:///glue.mysprykershop.com/wishlists http:///glue.mysprykershop.com/wishlists/{{wishlist_id}}/wishlists-items Send a request to https://glue.mysprykershop.com/customers/{{customer_id}}?include=wishlists and make sure that the given customer has at least one wishlist. Make sure that the response includes relationships to the wishlists resources.