Install the Product Comparison feature
Edit on GitHubThis document describes how to install the Product Comparison feature.
Install feature frontend
Follow the steps below to install the Product Comparison feature frontend.
Prerequisites
Install the required features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Spryker Core | 202410.0 | Install the Spryker Core feature |
Product | 202410.0 | Install the Product feature |
1) Install the required modules
Install the required modules using Composer:
composer require spryker-feature/product-comparison:"202410.0" --update-with-dependencies
Make sure the following modules have been installed:
MODULE | EXPECTED DIRECTORY |
---|---|
ProductComparisonPage | vendor/spryker-shop/product-comparison-page |
ProductComparisonWidget | vendor/spryker-shop/product-comparison-widget |
2) Add translations
Add translations as follows:
- Append glossary for the feature:
product_comparison_page.page_title,Artikel vergleichen,de_DE
product_comparison_page.page_title,Compare products,en_US
product_comparison_page.empty_comparison,Vergleichsliste ist leer.,de_DE
product_comparison_page.empty_comparison,Comparison list is empty.,en_US
product_comparison_page.clear-compare-list,Vergleichsliste leeren,de_DE
product_comparison_page.clear-compare-list,Clear the comparison list,en_US
product_comparison_page.add_to_comparison-list,Vergleichen,de_DE
product_comparison_page.add_to_comparison-list,Compare,en_US
product_comparison_page.remove_from_comparison-list,Aus Vergleich entfernen,de_DE
product_comparison_page.remove_from_comparison-list,Remove from Compare,en_US
product_comparison_page.list_link,Artikelvergleich,de_DE
product_comparison_page.list_link,Product comparison,en_US
product_comparison_page.add_to_comparison.success,Zum Vergleich hinzugefügt,de_DE
product_comparison_page.add_to_comparison.success,Added to comparison,en_US
product_comparison_page.add_to_comparison.error.max,Das Limit ist bereits erreicht,de_DE
product_comparison_page.add_to_comparison.error.max,The limit has already been reached,en_US
product_comparison_page.removed_from_the_list,Artikel wurde aus der Vergleichsliste entfernt.,de_DE
product_comparison_page.removed_from_the_list,Product was removed from the comparison list.,en_US
- Import data:
console data:import glossary
Make sure that the configured data has been added to the spy_glossary_key
and spy_glossary_translation
tables.
3) Set up router plugins
Register the following route provider plugins:
PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
---|---|---|---|
ProductComparisonPageRouteProviderPlugin | Adds the product comparison routes to the Yves application. | SprykerShop\Yves\ProductComparisonPage\Plugin\Router |
src/Pyz/Yves/Router/RouterDependencyProvider.php
<?php
namespace Pyz\Yves\Router;
use Spryker\Yves\Router\RouterDependencyProvider as SprykerRouterDependencyProvider;
use SprykerShop\Yves\ProductComparisonPage\Plugin\Router\ProductComparisonPageRouteProviderPlugin;
class RouterDependencyProvider extends SprykerRouterDependencyProvider
{
/**
* @return list<\Spryker\Yves\RouterExtension\Dependency\Plugin\RouteProviderPluginInterface>
*/
protected function getRouteProvider(): array
{
return [
new ProductComparisonPageRouteProviderPlugin(),
];
}
}
Make sure the product comparison page is available at https://mysprykershop.com/product-comparison
.
4) Set up widgets
Set up widgets as follows:
- Register the following plugins to enable widgets:
PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
---|---|---|---|
ComparisonProductTogglerComparisonListWidget | Displays the Compare and Remove from Compare buttons for adding and removing a product from the comparison list. | SprykerShop\Yves\ProductComparisonWidget\Widget | |
LinkToProductComparisonListWidget | Displays a link to the Product Comparison page. | SprykerShop\Yves\ProductComparisonWidget\Widget |
src/Pyz/Yves/ShopApplication/ShopApplicationDependencyProvider.php
<?php
namespace Pyz\Yves\ShopApplication;
use SprykerShop\Yves\ProductComparisonWidget\Widget\ComparisonProductTogglerComparisonListWidget;
use SprykerShop\Yves\ProductComparisonWidget\Widget\LinkToProductComparisonListWidget;
use SprykerShop\Yves\ShopApplication\ShopApplicationDependencyProvider as SprykerShopApplicationDependencyProvider;
class ShopApplicationDependencyProvider extends SprykerShopApplicationDependencyProvider
{
/**
* @return list<string>
*/
protected function getGlobalWidgets(): array
{
return [
ComparisonProductTogglerComparisonListWidget::class,
LinkToProductComparisonListWidget::class,
];
}
}
- Enable Javascript and CSS changes:
console frontend:yves:build
Verify that the following widgets have been registered by adding the respective code snippets to a Twig template:
WIDGET | VERIFICATION |
---|---|
ComparisonProductTogglerComparisonListWidget | Make sure that, on the product details page, you can add a product to a product comparison list. |
LinkToProductComparisonListWidget | Make sure that the Product comparison menu item is displayed in the menu bar. |
Thank you!
For submitting the form