Product reference field fails with Migrate 2.6 and with multivalue field in general

Created on 12 January 2015, over 10 years ago
Updated 4 May 2025, 2 months ago

I have a commerce product reference field that is mapped like this (on the product display entity):

    $this->addFieldMapping('field_product_ref', 'product_id')
      ->sourceMigration(array('ProductType1', 'ProductType2'));

When I upgrade to Migrate 2.6, all migrations fail with the following error:

Field validation errors

By debugging, in MigrateCommerceProductReferenceFieldHandler::prepare() we have $values an array:

array (
  'destid1' => '5037',
  'destid2' => '5030',
)

This is a single product entity with id = 5037 and revision_id = 5030, but the handler assigns two items with id = 5037 and id = 3030. The field validation added in Migrate 2.6 does not like it. Also, in general there could be problem with product reference multivalue fields.

I couldn't go further to see why it happens and how to fix. My workaround at the moment is not to use field mapping for this field.

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇫🇷France jcisio Paris

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