Install the Multiple Abstract Products as Promotional Products & Discounts feature
Edit on GitHubThis document describes how to add multiple abstract products as promotional products to the Promotions & Discounts feature.
Install feature core
Follow the steps below to install the feature core.
Prerequisites
Install the required features:
NAME | VERSION | INSTALLATION GUIDE |
---|---|---|
Promotions & Discounts | 202307.0 | Install the Promotions & Discounts feature |
Spryker Cart | 202307.0 | Install the Cart feature |
1) Install the required modules
Install the required modules using Composer:
composer require spryker/discount-promotions-rest-api "^1.4.0"
Make sure the following modules have been installed:
MODULE | EXPECTED DIRECTORY |
---|---|
DiscountPromotionsRestApi | vendor/spryker/discount-promotions-rest-api |
2) Set up database schema and transfer objects
Apply database changes and generate entity and transfer changes:
console transfer:generate
console propel:install
Ensure that the following changes have been applied by checking your database:
DATABASE ENTITY | TYPE | EVENT |
---|---|---|
spy_discount.abstract_skus | column | added |
Ensure that the following changes have been triggered in transfer objects:
TRANSFER | TYPE | EVENT | PATH |
---|---|---|---|
DiscountPromotionCriteria | class | created | src/Generated/Shared/Transfer/DiscountPromotionCriteriaTransfer |
DiscountPromotionCollection | class | created | src/Generated/Shared/Transfer/DiscountPromotionCollectionTransfer |
DiscountPromotionConditions | class | created | src/Generated/Shared/Transfer/DiscountPromotionConditionsTransfer |
PromotionItem | class | created | src/Generated/Shared/Transfer/PromotionItemTransfer |
DiscountPromotion | class | created | src/Generated/Shared/Transfer/DiscountPromotionTransfer |
ProductView | class | created | src/Generated/Shared/Transfer/ProductViewTransfer |
DiscountPromotion.abstractSkus | property | created | src/Generated/Shared/Transfer/DiscountPromotionTransfer |
Discount.idDiscount | property | created | src/Generated/Shared/Transfer/DiscountTransfer |
Discount.displayName | property | created | src/Generated/Shared/Transfer/DiscountTransfer |
Discount.discountPromotion | property | created | src/Generated/Shared/Transfer/DiscountTransfer |
RestPromotionalItemsAttributes.skus | property | created | src/Generated/Shared/Transfer/RestPromotionalItemsAttributesTransfer |
ProductView.promotionItem | property | created | src/Generated/Shared/Transfer/ProductViewTransfer |
Ensure that the ABSTRACT PRODUCT SKU(S)* field is displayed, and it accepts a comma-separated list:
- In the Back Office, go to Merchandising > Discount and select Create new discount.
- On the Create new discount page, in the Discount calculation tab, for DISCOUNT APPLICATION TYPE, select PROMOTIONAL PRODUCT.
- Ensure that the ABSTRACT PRODUCT SKU(S) field appears and add to it a comma-separated list of abstract product SKUs.
3) Add translations
Append glossary according to your configuration:
data/import/common/common/glossary.csv
cart.title.available_discounts,Verfügbare Rabatte,de_DE
cart.title.available_discounts,Available discounts,en_US
Import data:
console data:import glossary
Ensure that in the database the configured data are added to the spy_glossary
table.
4) Add Zed translations
Generate a new translation cache for Zed:
console translator:generate-cache
Ensure that all labels and help tooltips in the Discount form has English and German translation:
- In the Back Office, go to Merchandising > Discount.
- Create new discount or Edit an existing one.
- Check labels and help tooltips on the Create new discount or Edit discount page.
5) Set up behavior
Set up the following behaviors:
PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE |
---|---|---|---|
DiscountPromotionAddToCartFormWidgetParameterExpanderPlugin | Adds discount promotion form name postfix to the Add To Cart form. | None | SprykerShop\Yves\DiscountPromotionWidget\Plugin\CartPage\DiscountPromotionAddToCartFormWidgetParameterExpanderPlugin |
src/Pyz/Yves/CartPage/CartPageDependencyProvider.php
<?php
namespace Pyz\Yves\CartPage;
use SprykerShop\Yves\CartPage\CartPageDependencyProvider as SprykerCartPageDependencyProvider;
use SprykerShop\Yves\DiscountPromotionWidget\Plugin\CartPage\DiscountPromotionAddToCartFormWidgetParameterExpanderPlugin;
class CartPageDependencyProvider extends SprykerCartPageDependencyProvider
{
/**
* @return array<\SprykerShop\Yves\CartPageExtension\Dependency\Plugin\AddToCartFormWidgetParameterExpanderPluginInterface>
*/
protected function getAddToCartFormWidgetParameterExpanderPlugins(): array
{
return [
new DiscountPromotionAddToCartFormWidgetParameterExpanderPlugin(),
];
}
}
Ensure that the plugin works correctly:
- Create a discount.
- On the Discount calculation tab, for DISCOUNT APPLICATION TYPE, select PROMOTIONAL PRODUCT.
- Add ABSTRACT PRODUCT SKU.
- Create another discount with one or more identic promotional products.
- To fulfill the discounts’ requirements, add items to the cart.
- Ensure that both discounts are displayed in the Promotional Product section on the Cart page.
4) Build Zed UI frontend
Enable Javascript and CSS changes:
console frontend:zed:install-dependencies
console frontend:zed:build
Ensure that you can create a discount with multiple promotional products:
- In the Back Office, go to Merchandising > Discount.
- Click Create new discount or Edit next to the existing discount.
- Check that you can see the Discount form on the Create new discount or Edit discount page.
- On the Discount calculation tab, for DISCOUNT APPLICATION TYPE, select PROMOTIONAL PRODUCT.
- Ensure that the ABSTRACT PRODUCT SKU(S) field is displayed and that it accepts a comma-separated list.
- Enter several abstract product SKUs and save the discount.
- To fulfill the discount’s requirements, add items to the cart.
- Ensure that on the cart page, the Promotional Product section displays a carousel containing all products in the discount.
- Ensure that you can add a product from the Promotional Product section to the cart and that the discount is applied.
Thank you!
For submitting the form