diff --git a/code_samples/data_migration/examples/create_attribute_group.yaml b/code_samples/data_migration/examples/create_attribute_group.yaml index 292c96568d..d2b39fe984 100644 --- a/code_samples/data_migration/examples/create_attribute_group.yaml +++ b/code_samples/data_migration/examples/create_attribute_group.yaml @@ -22,11 +22,11 @@ options: choices: - value: red - label: - "eng-GB": "Red" + label: + "eng-GB": "Red" - value: white - label: - "eng-GB": "White" + label: + "eng-GB": "White" - value: black - label: - "eng-GB": "Black" + label: + "eng-GB": "Black" diff --git a/code_samples/data_migration/examples/create_product_asset.yaml b/code_samples/data_migration/examples/create_product_asset.yaml new file mode 100644 index 0000000000..64ce933e9b --- /dev/null +++ b/code_samples/data_migration/examples/create_product_asset.yaml @@ -0,0 +1,26 @@ +- type: content + mode: create + metadata: + contentType: image + mainTranslation: eng-GB + location: + parentLocationId: 51 # Media/Images + fields: + - fieldDefIdentifier: name + languageCode: eng-GB + value: 'Top hat 58cm Black' + - fieldDefIdentifier: image + languageCode: eng-GB + value: + alternativeText: 'Top hat 58cm Black' + fileName: 'top_hat_58cm_black.jpg' + path: top_hat_58cm_black.jpg + references: + - name: top_hat_58cm_black_image_content_id + type: content_id + +- type: product_asset + mode: create + product_code: top_hat__58__black + uri: '### "ezcontent://"~reference("top_hat_58cm_black_image_content_id") ###' + tags: [] diff --git a/code_samples/data_migration/examples/create_price.yaml b/code_samples/data_migration/examples/create_product_price.yaml similarity index 70% rename from code_samples/data_migration/examples/create_price.yaml rename to code_samples/data_migration/examples/create_product_price.yaml index 41bb5896dc..832e94059f 100644 --- a/code_samples/data_migration/examples/create_price.yaml +++ b/code_samples/data_migration/examples/create_product_price.yaml @@ -1,10 +1,10 @@ - type: product_price mode: create - product_code: 'DRESUN' + product_code: top_hat__58 currency_code: 'EUR' amount: 120 custom_prices: - - customer_group: wholesaler + - customer_group: contractors base_amount: 120 custom_amount: 100 diff --git a/code_samples/data_migration/examples/create_product_variant.yaml b/code_samples/data_migration/examples/create_product_variant.yaml new file mode 100644 index 0000000000..ace846de23 --- /dev/null +++ b/code_samples/data_migration/examples/create_product_variant.yaml @@ -0,0 +1,29 @@ +- type: content + mode: create + metadata: + contentType: hat + mainTranslation: eng-GB + location: + parentLocationId: 60 + fields: + - fieldDefIdentifier: name + languageCode: eng-GB + value: 'Top hat 58cm' + - fieldDefIdentifier: specification + languageCode: eng-GB + value: + code: top_hat__58 + attributes: + size: 58 + is_virtual: false + +- type: product_variant + mode: create + base_product_code: top_hat__58 + variants: + - code: top_hat__58__white + attributes: + color: white + - code: top_hat__58__black + attributes: + color: black diff --git a/docs/content_management/data_migration/importing_data.md b/docs/content_management/data_migration/importing_data.md index 94a9beeba1..e29dd526d0 100644 --- a/docs/content_management/data_migration/importing_data.md +++ b/docs/content_management/data_migration/importing_data.md @@ -61,8 +61,10 @@ The following data migration step modes are available: | `object_state` | ✔ | | | | `object_state_group` | ✔ | | | | `payment_method` | ✔ | | | +| `product_asset` | ✔ | | | | `product_availability` | ✔ | | | | `product_price` | ✔ | | | +| `product_variant` | ✔ | | | | `role` | ✔ | ✔ | ✔ | | `section` | ✔ | ✔ | | | `segment` | ✔ | ✔ | ✔ | @@ -246,7 +248,7 @@ Adjust the migration file and configure the `image` field data as follows: path: src/Migrations/images/example-image.png ``` -This migration copies the image to the appropriate directory, +This migration copies the image to the appropriate directory, in this case `public/var/site/storage/images/3/8/3/0/254-1-eng-GB/example-image.png`, enabling swift file migration regardless of storage (local, DFS). @@ -263,7 +265,7 @@ The following example shows the creation of a `Contributor` Role: [[= include_file('code_samples/data_migration/examples/create_role.yaml') =]] ``` -To update an existing Role, 2 policies' modes are available: +To update an existing Role, two policies' modes are available: - `replace`: (default) All existing policies are replaced by the ones from the migration. - `append`: Migration policies are added while already existing ones are kept. @@ -299,7 +301,7 @@ You can use an [action](data_migration_actions.md) to assign a Role to the user. [[= include_file('code_samples/data_migration/examples/create_user.yaml') =]] ``` -### Language +### Languages The following example shows how to create a language. @@ -311,6 +313,8 @@ The required metadata keys are: `languageCode`, `name`, and `enabled`. ### Product catalog +#### Attributes and attribute groups + The following example shows how to create an attribute group with two attributes: ``` yaml @@ -325,7 +329,7 @@ You can also update attributes, including changing which attribute group they be You can't change the attribute type of an existing attribute. -#### Product type +#### Product types The following example shows how to create a product type. @@ -338,38 +342,70 @@ A product type must also contain the definition for an `ibexa_product_specificat [[= include_file('code_samples/data_migration/examples/create_product_type.yaml') =]] ``` -#### Customer groups +#### Products -The following example shows how to create a customer group with a defined global price discount: +The following example shows how to create a product: ``` yaml -[[= include_file('code_samples/data_migration/examples/create_customer_group.yaml') =]] +[[= include_file('code_samples/data_migration/examples/create_product_variant.yaml', 1, 18) =]] ``` -#### Currencies +#### Product variants -The following example shows how to create a currency: +The following example shows how to create variants for a product identified by its code: ``` yaml -[[= include_file('code_samples/data_migration/examples/create_currency.yaml') =]] +[[= include_file('code_samples/data_migration/examples/create_product_variant.yaml', 20, 29) =]] +``` + +#### Product assets + +The following example creates an image [Content item](#content-items) from a local image file, and then uses it as a product asset for a variant ([created in previous example](#product-variant)): + +``` yaml +[[= include_file('code_samples/data_migration/examples/create_product_asset.yaml') =]] ``` -#### Prices +This migration uses a [reference](managing_migrations.md#references) to store the created image Content ID, and then uses it while creating the asset. +It uses an [expression syntax](#expression-syntax) to [concat (`~`)]([[= symfony_doc =]]/reference/formats/expression_language.html#string-operators) +the mandatory scheme `ezcontent://` and the image content ID through the [`reference` function](#built-in-functions) used on the reference's name. + +#### Product prices The following example shows how to create a price for a product identified by its code: ``` yaml -[[= include_file('code_samples/data_migration/examples/create_price.yaml') =]] +[[= include_file('code_samples/data_migration/examples/create_product_price.yaml') =]] +``` + +#### Customer groups + +The following example shows how to create a customer group with a defined global price discount: + +``` yaml +[[= include_file('code_samples/data_migration/examples/create_customer_group.yaml') =]] +``` + +#### Currencies + +The following example shows how to create a currency: + +``` yaml +[[= include_file('code_samples/data_migration/examples/create_currency.yaml') =]] ``` ### Commerce [[% include 'snippets/commerce_badge.md' %]] +#### Payment methods + The following example shows how to create a payment method: ``` yaml [[= include_file('code_samples/data_migration/examples/create_payment_method.yaml') =]] ``` +#### Shipping methods + The following example shows how to create a shipping method: ``` yaml