How to add a custom catalog promotion action?
Sylius offers flexible catalog promotions that allow dynamic product price adjustments per sales channel. This guide shows you how to create a custom catalog promotion action that sets a fixed price for products based on the channel. You will integrate the following components:
Custom price calculator logic
Admin form integration
By the end of this guide, you will have a fully integrated catalog promotion action within the Sylius Admin Panel and API.
1. Create the Price Calculator Service
The price calculator determines the new price for each product variant per channel using your custom logic.
Service Registration
Register the price calculator service:
# config/services.yaml
services:
App\Calculator\FixedPriceCalculator:
tags:
- { name: 'sylius.catalog_promotion.price_calculator', type: 'fixed_price' }FixedPriceCalculator Class
Create the FixedPriceCalculator class to handle price calculations for each channel:
2. Build the Admin Configuration Form
This form allows admins to set fixed prices per channel.
Service Registration
Register the admin form service:
FixedPriceConfigurationType Form
This form enables the admin to set a fixed price for each channel:
ChannelBasedFixedPriceActionConfigurationType Form
This form handles the configuration of fixed prices for each channel:
3. Configure Translations
Add the necessary translation labels for your custom action.
Add Translation for Action Type
In the translations/messages.en.yaml file, define the label for your fixed price action:
4. Custom Validation (Optional)
Tip: For customizing validation rules (e.g., enforcing price constraints), refer to Sylius' Custom Validation Guide.
β
Result


You can now select "Fixed Price" as a action type when creating or editing catalog promotions.
If your catalog promotion is not active, make sure the Messenger worker is active:
Last updated
Was this helpful?
