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 diff --git a/docs/content_management/data_migration/importing_data.md b/docs/content_management/data_migration/importing_data.md index 312b888838..36c9e67dd1 100644 --- a/docs/content_management/data_migration/importing_data.md +++ b/docs/content_management/data_migration/importing_data.md @@ -507,6 +507,21 @@ 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 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') =]] +``` + ## Criteria When using `update` or `delete` modes, you can use criteria to identify the objects to operate on.