You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These events are dispatched by the back office controllers after user chooses the "Save" action when creating or updating a discount.
61
63
62
64
| Event | Dispatched by | Description |
63
65
|---|---|---|
64
-
[PreDiscountCreateEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountCreateEvent.html) | `Ibexa\Bundle\Discounts\Controller\DiscountCreateController` | Dispatched when the discount creation is finished in the back office form |
65
-
[PreDiscountUpdateEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountUpdateEvent.html) | `Ibexa\Bundle\Discounts\Controller\DiscountEditController` | Dispatched when the discount modifications is finished in the back office form |
66
+
|[`PreDiscountCreateEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountCreateEvent.html)|`Ibexa\Bundle\Discounts\Controller\DiscountCreateController`| Dispatched when the discount creation is finished in the back office form |
67
+
|[`PreDiscountUpdateEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountUpdateEvent.html)|`Ibexa\Bundle\Discounts\Controller\DiscountEditController`| Dispatched when the discount modifications is finished in the back office form |
66
68
67
69
## Discount codes
68
70
69
71
The event below allows you to inject your custom logic before the discount code is applied to a product in cart:
70
72
71
73
| Event | Dispatched by | Description |
72
74
|---|---|---|
73
-
|[BeforeDiscountCodeApplyEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Event-BeforeDiscountCodeApplyEvent.html)|`Ibexa\Bundle\DiscountsCodes\Controller\REST\DiscountCodeController`| Dispatched before a discount code is applied in the cart |
75
+
|[`BeforeDiscountCodeApplyEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Event-BeforeDiscountCodeApplyEvent.html)|`Ibexa\Bundle\DiscountsCodes\Controller\REST\DiscountCodeController`| Dispatched before a discount code is applied in the cart |
Copy file name to clipboardExpand all lines: docs/discounts/configure_discounts.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,35 @@ ibexa:
30
30
products_list_per_page_limit: 15
31
31
```
32
32
33
+
## Discount re-indexing
34
+
35
+
Discounts feature uses [[= product_name_base =]] Messenger to reindex discounts and product prices as [background tasks](background_tasks.md).
36
+
This way changes are processed efficiently without slowing down the system and disrupting the user experience.
37
+
38
+
When triggered periodically, the `ibexa:discounts:reindex` command identifies discounts that require re-indexing, ensuring prices always remain up-to-date.
39
+
If there are edits to discounts that should result in changed product catalog prices, messages are dispatched to the [[= product_name_base =]] Messenger's queue and consumed by a background worker.
40
+
The worker passes the messages to the handler, which then starts the re-indexing process at the most convenient moment.
41
+
42
+
To run discount re-indexing in the background:
43
+
44
+
1\. Make sure that the transport layer is [defined properly](background_tasks.md#configure-package) in [[= product_name_base =]] Messenger configuration.
45
+
46
+
2\. Make sure that the [worker starts](background_tasks.md#start-worker) together with the application to watch the transport bus:
3\. Use a scheduler of your choice, for example, [cron](https://en.wikipedia.org/wiki/Cron), to periodically run the following command:
53
+
54
+
``` bash
55
+
php bin/console ibexa:discounts:reindex
56
+
```
57
+
58
+
!!! note "Deploying Symfony Messenger"
59
+
60
+
For more information about deploying the Messenger to production, see [Symfony documentation]([[= symfony_doc =]]/messenger.html#deploying-to-production).
61
+
33
62
## Rate limiting
34
63
35
64
To prevent malicious actors from trying all the possible discount code combinations using brute-force attacks, the [`/discounts_codes/{cartIdentifier}/apply` endpoint](/api/rest_api/rest_api_reference/rest_api_reference.html#discount-codes-apply-discount-to-cart) is rate limited using the [Rate Limiter Symfony component]([[= symfony_doc =]]/rate_limiter.html).
Copy file name to clipboardExpand all lines: docs/discounts/discounts_guide.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,6 +113,15 @@ You can also limit the usage per customer:
113
113
- limited use: every customer can use the code a specified number of times
114
114
- unlimited
115
115
116
+
### Discount re-indexing
117
+
118
+
Discounts affect the prices shown in the product catalog.
119
+
When a discount is created, updated, or expires, the product catalog must be re-indexed to ensure that the search results and product listings display correct prices.
120
+
121
+
To prevent performance disruptions which could occur if re-indexing occurred immediately, [[= product_name =]] uses the [[= product_name_base =]] Messenger's [background queue](background_tasks.md) to process re-indexing tasks in the background.
122
+
123
+
By [configuring the process](configure_discounts.md#discount-re-indexing), you ensure that re-indexing is performed at the most convenient time to maintain your application's overall stability.
0 commit comments