0

Many months ago, I wrote a migration for Commerce products from Drupal 7 to Drupal 10 and successfully migrated those products. However, now I need to migrate the GUIDs from the feeds_item table in Drupal 7 into the "Feeds item" field of the product in Drupal 10. I implemented the following migration:

id: commerce_product_feeds_item_guids_migration migration_group: migrate_drupal_7 label: 'Commerce Product Feeds item GUIDs migration' source: plugin: drupal_seven_migration_product_feeds_item_guid product_type: products process: feeds_item/target_id: plugin: default_value default_value: '3' strict: 0 feeds_item/guid: guid destination: plugin: 'entity:commerce_product' destination_module: commerce_product default_bundle: product_line # update fields 

The issue:
When I ran the following command:
drush migrate:import commerce_product_feeds_item_guids_migration --update
instead of updating the "Feeds item" field in the existing product, a new product was created.

Someone suggested that it might be possible to specify something in the destination section so that the migration simply updates the necessary fields of the existing product instead of creating a new one - but they couldn’t recall exactly what needs to be added.

Question:
What exactly should be specified in the destination section? Or how can I fix this issue?

2 Answers 2

2

Without --update, only new products created on the source will be created on the target site. With --update, you are implicitly saying that you want all the content to get updated, even those that were already created (which is what you want).

But for that to work, migrate needs to know how to find those on the migration source and the target site. There's a source property ids that is not being specified on your migration.

Without seeing your source plugin, we cannot know if you have a source id for doing that matching. Assuming one is provided in the plugin, and you have kept your migrate_*** mapping tables, it should work.

1

The solution:

 id: commerce_product_feeds_item_guids_migration migration_group: migrate_drupal_7 label: 'Commerce Product Feeds item GUIDs migration' source: plugin: drupal_seven_migration_product_feeds_item_guid product_type: products process: product_id: # added - plugin: migration_lookup migration: commerce_products_migration source: nid no_stub: true feeds_item/target_id: plugin: default_value default_value: '120' strict: 0 feeds_item/guid: guid destination: plugin: 'entity:commerce_product' destination_module: commerce_product default_bundle: product_line overwrite_properties: # added - feeds_item migration_dependencies: required: { } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.