I'm writing a custom migration module from a legacy system. I have all of my orders and order items being migrated, but the commerce_order__order_items
table is not being populated.
My orders migration:
id: my_order_data
label: My orders
migration_group: mygroup
migration_tags:
- kentico
- orders
source:
plugin: csv
ids: [OrderID]
path: 'public://import/program/orders.data.csv'
header_row_count: 1
process:
order_number: OrderInvoiceNumber
type:
plugin: static_map
source: type
default_value: default
map:
commerce_order: default
uid:
-
plugin: migration_lookup
migration: my_user_data
source: OrderCreatedByUserID
no_stub: true
-
plugin: default_value
default_value: 0
strict: true
-
plugin: entity_exists
entity_type: user
-
plugin: default_value
default_value: 0
state:
plugin: default_value
default_value: completed
created:
plugin: callback
source: OrderDate
callable: strtotime
changed:
plugin: callback
source: OrderLastModified
callable: strtotime
placed:
plugin: callback
source: OrderDate
callable: strtotime
completed:
plugin: callback
source: OrderDate
callable: strtotime
mail: CustomerEmail
store_id:
plugin: default_value
default_value: 1
billing_profile_data:
-
plugin: migration_lookup
migration: my_profile_data
source: OrderBillingAddressID
no_stub: true
billing_profile/target_id:
-
plugin: skip_on_empty
method: process
source: '@billing_profile_data'
-
plugin: extract
index: [0]
billing_profile/target_revision_id:
-
plugin: skip_on_empty
method: process
source: '@billing_profile_data'
-
plugin: extract
index: [0]
total_price/number: OrderTotalNumber
total_price/currency_code:
plugin: default_value
default_value: 'USD'
total_paid/number: OrderTotalNumber
total_paid/currency_code:
plugin: default_value
default_value: 'USD'
adjustments:
plugin: my_order_adjustment_shipping
destination:
plugin: entity:commerce_order
destination_module: commerce_order
migration_dependencies:
required:
- my_user_data
- my_profile_data
dependencies:
enforced:
module:
- my_migration
My order items:
id: my_order_item_data
label: My order items
migration_group: mygroup
migration_tags:
- kentico
- orders
- items
source:
plugin: csv
ids: [OrderItemID]
path: 'public://import/program/order-items.data.csv'
header_row_count: 1
process:
type:
plugin: default_value
default_value: 'default'
order_id:
-
plugin: migration_lookup
migration: my_order_data
source: OrderItemOrderID
no_stub: true
-
plugin: default_value
default_value: 0
strict: true
-
plugin: entity_exists
entity_type: commerce_order
-
plugin: default_value
default_value: 0
purchased_entity:
bar:
plugin: static_map
source: OrderItemSKUID
map:
377: 67
378: 66
...
default_value: 0
title: OrderItemSKUName
quantity: OrderItemUnitCount
unit_price/number: OrderItemUnitPrice
unit_price/currency_code:
plugin: default_value
default_value: 'USD'
total_price/number: OrderItemTotalPriceInMainCurrency
total_price/currency_code:
plugin: default_value
default_value: 'USD'
created:
plugin: callback
source: OrderItemLastModified
callable: strtotime
changed:
plugin: callback
source: OrderItemLastModified
callable: strtotime
uses_legacy_adjustments:
plugin: default_value
default_value: false
destination:
plugin: entity:commerce_order_item
destination_module: commerce_order
migration_dependencies:
required:
- my_order_data
dependencies:
enforced:
module:
- my_migration
I've tried to look into custom process functions, but I'm afraid I don't know where to really start with that. The commerce migrate module isn't terribly helpful with it's CSV example.