Skip to content

Commit 55c2e12

Browse files
authored
Continue product migration doc (4.6) (#2181)
1 parent 24f0f75 commit 55c2e12

File tree

5 files changed

+111
-20
lines changed

5 files changed

+111
-20
lines changed

code_samples/data_migration/examples/create_attribute_group.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
options:
2323
choices:
2424
- value: red
25-
label:
26-
"eng-GB": "Red"
25+
label:
26+
"eng-GB": "Red"
2727
- value: white
28-
label:
29-
"eng-GB": "White"
28+
label:
29+
"eng-GB": "White"
3030
- value: black
31-
label:
32-
"eng-GB": "Black"
31+
label:
32+
"eng-GB": "Black"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- type: content
2+
mode: create
3+
metadata:
4+
contentType: image
5+
mainTranslation: eng-GB
6+
location:
7+
parentLocationId: 51 # Media/Images
8+
fields:
9+
- fieldDefIdentifier: name
10+
languageCode: eng-GB
11+
value: 'Top hat 58cm Black'
12+
- fieldDefIdentifier: image
13+
languageCode: eng-GB
14+
value:
15+
alternativeText: 'Top hat 58cm Black'
16+
fileName: 'top_hat_58cm_black.jpg'
17+
path: top_hat_58cm_black.jpg
18+
references:
19+
- name: top_hat_58cm_black_image_content_id
20+
type: content_id
21+
22+
- type: product_asset
23+
mode: create
24+
product_code: top_hat__58__black
25+
uri: '### "ezcontent://"~reference("top_hat_58cm_black_image_content_id") ###'
26+
tags: []
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
- type: product_price
22
mode: create
3-
product_code: 'DRESUN'
3+
product_code: top_hat__58
44
currency_code: 'EUR'
55
amount: 120
66
custom_prices:
7-
- customer_group: wholesaler
7+
- customer_group: contractors
88
base_amount: 120
99
custom_amount: 100
1010

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
- type: content
2+
mode: create
3+
metadata:
4+
contentType: hat
5+
mainTranslation: eng-GB
6+
location:
7+
parentLocationId: 60
8+
fields:
9+
- fieldDefIdentifier: name
10+
languageCode: eng-GB
11+
value: 'Top hat 58cm'
12+
- fieldDefIdentifier: specification
13+
languageCode: eng-GB
14+
value:
15+
code: top_hat__58
16+
attributes:
17+
size: 58
18+
is_virtual: false
19+
20+
- type: product_variant
21+
mode: create
22+
base_product_code: top_hat__58
23+
variants:
24+
- code: top_hat__58__white
25+
attributes:
26+
color: white
27+
- code: top_hat__58__black
28+
attributes:
29+
color: black

docs/content_management/data_migration/importing_data.md

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ The following data migration step modes are available:
6565
| `object_state` | ✔ | | |
6666
| `object_state_group` | ✔ | | |
6767
| `payment_method` | ✔ | | |
68+
| `product_asset` | ✔ | | |
6869
| `product_availability` | ✔ | | |
6970
| `product_price` | ✔ | | |
71+
| `product_variant` | ✔ | | |
7072
| `role` | ✔ | ✔ | ✔ |
7173
| `section` | ✔ | ✔ | |
7274
| `segment` | ✔ | ✔ | ✔ |
@@ -250,7 +252,7 @@ Adjust the migration file and configure the `image` field data as follows:
250252
path: src/Migrations/images/example-image.png
251253
```
252254

253-
This migration copies the image to the appropriate directory,
255+
This migration copies the image to the appropriate directory,
254256
in this case `public/var/site/storage/images/3/8/3/0/254-1-eng-GB/example-image.png`,
255257
enabling swift file migration regardless of storage (local, DFS).
256258

@@ -267,7 +269,7 @@ The following example shows the creation of a `Contributor` Role:
267269
[[= include_file('code_samples/data_migration/examples/create_role.yaml') =]]
268270
```
269271

270-
To update an existing Role, 2 policies' modes are available:
272+
To update an existing Role, two policies' modes are available:
271273

272274
- `replace`: (default) All existing policies are replaced by the ones from the migration.
273275
- `append`: Migration policies are added while already existing ones are kept.
@@ -303,7 +305,7 @@ You can use an [action](data_migration_actions.md) to assign a Role to the user.
303305
[[= include_file('code_samples/data_migration/examples/create_user.yaml') =]]
304306
```
305307

306-
### Language
308+
### Languages
307309

308310
The following example shows how to create a language.
309311

@@ -315,6 +317,8 @@ The required metadata keys are: `languageCode`, `name`, and `enabled`.
315317

316318
### Product catalog
317319

320+
#### Attributes and attribute groups
321+
318322
The following example shows how to create an attribute group with two attributes:
319323

320324
``` yaml
@@ -329,7 +333,7 @@ You can also update attributes, including changing which attribute group they be
329333

330334
You can't change the attribute type of an existing attribute.
331335

332-
#### Product type
336+
#### Product types
333337

334338
The following example shows how to create a product type.
335339

@@ -342,38 +346,70 @@ A product type must also contain the definition for an `ibexa_product_specificat
342346
[[= include_file('code_samples/data_migration/examples/create_product_type.yaml') =]]
343347
```
344348

345-
#### Customer groups
349+
#### Products
346350

347-
The following example shows how to create a customer group with a defined global price discount:
351+
The following example shows how to create a product:
348352

349353
``` yaml
350-
[[= include_file('code_samples/data_migration/examples/create_customer_group.yaml') =]]
354+
[[= include_file('code_samples/data_migration/examples/create_product_variant.yaml', 1, 18) =]]
351355
```
352356

353-
#### Currencies
357+
#### Product variants
354358

355-
The following example shows how to create a currency:
359+
The following example shows how to create variants for a product identified by its code:
356360

357361
``` yaml
358-
[[= include_file('code_samples/data_migration/examples/create_currency.yaml') =]]
362+
[[= include_file('code_samples/data_migration/examples/create_product_variant.yaml', 20, 29) =]]
363+
```
364+
365+
#### Product assets
366+
367+
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)):
368+
369+
``` yaml
370+
[[= include_file('code_samples/data_migration/examples/create_product_asset.yaml') =]]
359371
```
360372

361-
#### Prices
373+
This migration uses a [reference](managing_migrations.md#references) to store the created image Content ID, and then uses it while creating the asset.
374+
It uses an [expression syntax](#expression-syntax) to [concat (`~`)]([[= symfony_doc =]]/reference/formats/expression_language.html#string-operators)
375+
the mandatory scheme `ezcontent://` and the image content ID through the [`reference` function](#built-in-functions) used on the reference's name.
376+
377+
#### Product prices
362378

363379
The following example shows how to create a price for a product identified by its code:
364380

365381
``` yaml
366-
[[= include_file('code_samples/data_migration/examples/create_price.yaml') =]]
382+
[[= include_file('code_samples/data_migration/examples/create_product_price.yaml') =]]
383+
```
384+
385+
#### Customer groups
386+
387+
The following example shows how to create a customer group with a defined global price discount:
388+
389+
``` yaml
390+
[[= include_file('code_samples/data_migration/examples/create_customer_group.yaml') =]]
391+
```
392+
393+
#### Currencies
394+
395+
The following example shows how to create a currency:
396+
397+
``` yaml
398+
[[= include_file('code_samples/data_migration/examples/create_currency.yaml') =]]
367399
```
368400

369401
### Commerce [[% include 'snippets/commerce_badge.md' %]]
370402

403+
#### Payment methods
404+
371405
The following example shows how to create a payment method:
372406

373407
``` yaml
374408
[[= include_file('code_samples/data_migration/examples/create_payment_method.yaml') =]]
375409
```
376410

411+
#### Shipping methods
412+
377413
The following example shows how to create a shipping method:
378414

379415
``` yaml

0 commit comments

Comments
 (0)