Commerce Migrate failing to properly migrate product references

Created on 17 February 2017, over 8 years ago
Updated 4 May 2025, 2 months ago

When trying to set product variant references during a product display migration using the latest DEV branch of 7.x, as well as the patched version of 7.x-1.2 that ships with Commerce Kickstart 7.x-2.43, two problems occur:

  1. For single-sku products, two entries are created in the field_data_field_product table for each product display/variant combo, but one with a delta of 0 and the other delta 1.
  2. For multi-sku products, the migration fails with a SQL update error: "SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1: INSERT INTO…"

This problem does NOT occur for Commerce Migrate 7.x-1.2. That version of the module migrates both single and multi-sku products correctly.

The problem appears to be related to the patch from https://www.drupal.org/node/2701333 . The patch updates MigrateCommerceProductReferenceFieldHandler to extend MigrateSimpleFieldHandler in place of custom logic previously applied to MigrateFieldHandler. This patch appears to have been implemented in 7.x-1.x-dev, and it has been applied to the 7.x-1.2 stable version that comes with Commerce Kickstart. In both cases, my migration fails the same way when using either version to migrate products. However, when I switch to the unpatched 7.x-1.2 version, the migration happens without errors.

For my migration, I have one product display that aggregates three different variant types, so the product reference field mapping includes a sourceMigration() consisting of an array of three previous variant migrations. Not sure if that is relevant here, but figured I'd mention it.

I have NOT yet tried the solution in this bug report: https://www.drupal.org/node/2405869 . That workaround appears to bypass sourceMigration() entirely by looking up the Drupal ID of the previously migrated SKUs by their SKU value within the prepareRow() method. That might be a solution, but it's not ideal because it should not be necessary: sourceMigration() is supposed to do this for you when setting up entity reference fields in general.

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇺🇸United States daletrexel Minnesota, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024