From 9895158cddf71a4cc3e4f1005186fd7060c2d934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 4 Jun 2025 14:56:33 +0200 Subject: [PATCH 1/3] [Discounts] Added migration doc --- .../data_migration/importing_data.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/content_management/data_migration/importing_data.md b/docs/content_management/data_migration/importing_data.md index 312b888838..12a89b2040 100644 --- a/docs/content_management/data_migration/importing_data.md +++ b/docs/content_management/data_migration/importing_data.md @@ -507,6 +507,20 @@ When updating a content type, use: [[= include_file('code_samples/data_migration/examples/ai/action_configuration_delete.yaml') =]] ``` +### Discounts [[% include 'snippets/lts-update_badge.md' %]] + +- The following example shows how you can create a new [discount](discounts_guide.md) in your system: + +``` yaml +[[= include_file('code_samples/data_migration/examples/discounts/discount_create.yaml') =]] +``` + +- Use the `update` mode to modify an existing discount: + +``` yaml +[[= include_file('code_samples/data_migration/examples/discounts/discount_update.yaml') =]] +``` + ## Criteria When using `update` or `delete` modes, you can use criteria to identify the objects to operate on. From eeeda5c788e6d92c0eac12d2407d47ba288d24b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 4 Jun 2025 14:57:28 +0200 Subject: [PATCH 2/3] Added files --- .../examples/discounts/discount_create.yaml | 37 +++++++++++++++++++ .../examples/discounts/discount_update.yaml | 29 +++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 code_samples/data_migration/examples/discounts/discount_create.yaml create mode 100644 code_samples/data_migration/examples/discounts/discount_update.yaml diff --git a/code_samples/data_migration/examples/discounts/discount_create.yaml b/code_samples/data_migration/examples/discounts/discount_create.yaml new file mode 100644 index 0000000000..e3000b4ec7 --- /dev/null +++ b/code_samples/data_migration/examples/discounts/discount_create.yaml @@ -0,0 +1,37 @@ +- type: discount + mode: create + identifier: summer_sale_2025 + translations: + - + language_code: eng-GB + name: "Summer Sale 2025" + description: "-10% on laptops" + label: "HOT DEAL: Summer Sale!" + label_description: "Get 10% off on selected items!" + discount_type: cart + priority: 8 + enabled: true + user: admin + startDate: '2024-01-01T00:01:00+00:00' + endDate: null + createdAt: null + updatedAt: null + rule: + type: percentage + expressionValues: + discount_percentage: 10 + conditions: + - + identifier: is_in_currency + expressionValues: + currency_code: EUR + - + identifier: is_product_in_array + expressionValues: + product_codes: + - product_code_book_0 + - product_code_book_1 + - + identifier: is_product_in_quantity_in_cart + expressionValues: + quantity: 2 diff --git a/code_samples/data_migration/examples/discounts/discount_update.yaml b/code_samples/data_migration/examples/discounts/discount_update.yaml new file mode 100644 index 0000000000..6c40304fc2 --- /dev/null +++ b/code_samples/data_migration/examples/discounts/discount_update.yaml @@ -0,0 +1,29 @@ +- type: discount + mode: update + match: + field: identifier + value: summer_sale_2025 + identifier: summer_sale_2025_updated + translations: + eng-GB: + language_code: eng-GB + name: Updated name + description: Updated description + label: Updated promotion label + label_description: Updated promotion description + priority: 5 + active: true + user: admin + startDate: '2024-01-01T00:00:00+00:00' + endDate: null + createdAt: null + updatedAt: null + rule: + type: percentage + expressionValues: + discount_percentage: '10' + conditions: + - + identifier: is_product_in_quantity_in_cart + expressionValues: + quantity: 2 From 6756851bd00bc9f94ddab17a64488ab1fe7c829c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 4 Jun 2025 16:26:17 +0200 Subject: [PATCH 3/3] Update docs/content_management/data_migration/importing_data.md --- docs/content_management/data_migration/importing_data.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/content_management/data_migration/importing_data.md b/docs/content_management/data_migration/importing_data.md index 12a89b2040..36c9e67dd1 100644 --- a/docs/content_management/data_migration/importing_data.md +++ b/docs/content_management/data_migration/importing_data.md @@ -515,7 +515,8 @@ When updating a content type, use: [[= include_file('code_samples/data_migration/examples/discounts/discount_create.yaml') =]] ``` -- Use the `update` mode to modify an existing discount: +- Use the `update` mode to modify an existing discount as in the example below. +The provided conditions overwrite any already existing ones. ``` yaml [[= include_file('code_samples/data_migration/examples/discounts/discount_update.yaml') =]]