Alternative Products Feature Integration

Install Feature Core

Prerequisites

To start feature integration, overview and install the necessary features:

Name Version
Product 201903.0
Spryker Core 201903.0

1) Install the Required Modules Using Composer

Run the following command(s) to install the required modules:

composer require spryker-feature/alternative-products: "^201903.0" --update-with-dependencies

Make sure that the following modules were installed:

Module Expected Directory
ProductAlternative vendor/spryker/product-alternative
ProductAlternativeDataImport vendor/spryker/product-alternative-data-import
ProductAlternativeGui vendor/spryker/product-alternative-gui
ProductAlternativeStorage vendor/spryker/product-alternative-storage

2) Set up Database Schema and Transfer Objects

Adjust the schema definition so that entity changes trigger the events.

Affected Entity Triggered Events
spy_product_alternative Entity.spy_product_alternative.create
Entity.spy_product_alternative.update
Entity.spy_product_alternative.delete

Set up synchronization queue pools so that non-multistore entities (not store specific entities) get synchronized among stores:

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

console transfer:generate
console propel:install
console transfer:generate

Make sure that the following changes applied by checking your database:

Database Entity Type Event
spy_product_alternative table created
spy_product_alternative_storage table created
spy_product_replacement_for_storage table created

Make sure that the following changes in transfer objects:

Transfer Type Event Path
SpyProductAlternativeEntityTransfer class created src/Generated/Shared/Transfer/SpyProductAlternativeEntityTransfer
SpyProductAlternativeStorageEntityTransfer class created src/Generated/Shared/Transfer/SpyProductAlternativeStorageEntityTransfer
SpyProductReplacementForStorageEntityTransfer class created src/Generated/Shared/Transfer/SpyProductReplacementForStorageEntityTransfer
ProductAlternative class created src/Generated/Shared/Transfer/ProductAlternative
ProductAlternativeResponse class created src/Generated/Shared/Transfer/ProductAlternativeResponse
ResponseMessage class created src/Generated/Shared/Transfer/ResponseMessage
ProductAlternativeCollection class created src/Generated/Shared/Transfer/ProductAlternativeCollection
ProductAlternativeCreateRequest class created src/Generated/Shared/Transfer/ProductAlternativeCreateRequest
ProductAlternativeListItem class created src/Generated/Shared/Transfer/ProductAlternativeListItem
ProductAlternativeList class created src/Generated/Shared/Transfer/ProductAlternativeList
ProductAlternativeStorage class created src/Generated/Shared/Transfer/ProductAlternativeStorage
ProductReplacementStorage class created src/Generated/Shared/Transfer/ProductReplacementStorage

Make sure that the changes were implemented successfully. For this purpose, trigger the following methods and make sure that the above events have been triggered:

Path Method Name
src/Orm/Zed/ProductAlternative/Persistence/Base/SpyProductAlternative.php prepareSaveEventName()
addSaveEventToMemory()
addDeleteEventToMemory()

3) Configure Export to Redis

This step will publish tables on change (create, edit, delete) to the spy_product_alternative_storage, spy_product_replacement_for_storage and synchronize the data to Storage.

Setup Event Listeners

Plugin Specification Prerequisites Namespace
ProductAlternativeStorageEventSubscriber Registers listeners that are responsible to publish alternative products storage entity changes when a related entity change event occurs. None Spryker\Zed\ProductAlternativeStorage\Communication\Plugin\Event\Subscriber

Setup Re-Generate and Re-Sync Features

Plugin Specification Prerequisites Namespace
ProductAlternativeSynchronizationDataPlugin Allows synchronizing the whole storage table content into Storage. None Spryker\Zed\ProductAlternativeStorage\Communication\Plugin\Synchronization
ProductReplacementForSynchronizationDataPlugin Allows synchronizing the whole storage table content into Storage. None Spryker\Zed\ProductAlternativeStorage\Communication\Plugin\Synchronization

4) Import Data

Import Product Alternatives

The following imported entities will be used as alternative products in the Spryker OS.

Prepare your data according to your requirements using our demo data:

Column Is Obligatory? Data Type Data Example Data Explanation
concrete_sku mandatory string 420566 SKU of concrete product which will have alternative products.
alternative_product_concrete_sku optional string 420565 SKU of the concrete alternative product.
alternative_product_abstract_sku optional string M1000785 SKU of the abstract alternative product.

Register the following plugin to enable data import:

Plugin Specification Prerequisites Namespace
ProductAlternativeDataImportPlugin Imports alternative product data into the database. None Spryker\Zed\ProductAlternativeDataImport\Communication\Plugin

Run the following console command to import data:

console data:import product-alternative

Make sure that in the database that the configured data are added to the spy_product_alternative table.

5) Set up Behavior

Setup Alternative Products Workflow

Enable the following behaviors by registering the plugins:

Plugin Specification Prerequisites Namespace
ProductConcretePluginUpdate Saves product alternatives on product concrete save. None Spryker\Zed\ProductAlternativeGui\Communication\Plugin\Product
ProductConcreteFormEditTabsExpanderPlugin Expands form tabs for ProductConcreteEditForm with Product Alternatives section. None Spryker\Zed\ProductAlternativeGui\Communication\Plugin\ProductManagement
ProductConcreteEditFormExpanderPlugin Expands ProductConcreteEditForm with AddProductAlternativeForm form. None Spryker\Zed\ProductAlternativeGui\Communication\Plugin\ProductManagement
ProductConcreteFormEditDataProviderExpanderPlugin Adds alternative product information to ProductConcreteEditForm data. Expected idProductConcrete set for ProductConcreteTransfer. Spryker\Zed\ProductAlternativeGui\Communication\Plugin\ProductManagement
ProductFormTransferMapperExpanderPlugin Adds product alternative create requests to product concrete transfer. None Spryker\Zed\ProductAlternativeGui\Communication\Plugin\ProductManagement

Make sure that when you edit any product variant in Zed you have "Product Alternatives" tab, and you can add some product SKU's as alternatives.

Install Feature Frontend

Prerequisites

Please overview and install the necessary features before beginning the integration step.

Name Version
Product 201903.0
Spryker Core 201903.0

1) Install the Required Modules Using Composer

Run the following command(s) to install the required modules:

composer require spryker-feature/alternative-products: "^201903.0" --update-with-dependencies

Make sure that the following modules were installed:

Module Expected Directory
ProductAlternativeWidget vendor/spryker-shop/product-alternative-widget
ProductReplacementForWidget vendor/spryker-shop/product-replacement-for-widget

2) Add Translations

Append glossary according to your configuration:

Run the following console command to import data:

console data:import glossary

Make sure that in the database the configured data are added to the spy_glossary table.

3) Set up Widgets

Register the following plugins to enable widgets:

Plugin Description Prerequisites Namespace
ProductAlternativeWidget Displays alternative product. None SprykerShop\Yves\ProductWidget\Widget
PdpProductReplacementForListWidget Displays list of products for replacement. None SprykerShop\Yves\ProductWidget\Widget
ProductReplacementForListWidget Displays product for replacement. None SprykerShop\Yves\ProductReplacementForWidget\Widget
ProductAlternativeListWidget Display list of alternative products for the provided product. None SprykerShop\Yves\ProductAlternativeWidget\Widget

Run the following command to enable Javascript and CSS changes:

console frontend:yves:build

Make sure that the following widgets were registered:

Module Test
ProductAlternativeWidget Assign some alternative products in Zed, and make sure that they are displayed on the detail page of the product to which they were assigned.
ProductReplacementForListWidget Make that after you've assigned some product as an alternative for another you can see "Replacement for" section on its product detail page.
PdpProductReplacementForListWidget Make that after you've assigned some product as an alternative for another you can see "Replacement for" section on its product detail page.
ProductAlternativeListWidget Assign some alternative products in Zed, and make sure that they are displayed on the PDP of the product to which they were assigned.

 

See also:

 

Last review date: Mar 29, 2019