#StackBounty: #8 #users #migration Map profile_id based on previously mapped uid when migrating user profiles from CSV file

Bounty: 50

I’m trying to migrate users and user profiles to site, where both entities might be already present. In this case I would like to overwrite specified fields and leave others in the original state. I’m trying to map profile_id like this:

    plugin: migration_lookup
    no_stub: true
    # previous user migration
    migration: mayors_users
    # property in the source data
    source: lau
    plugin: entity_lookup
    entity_type: profile
    bundle: profile
    bundle_key: type
    value_key: uid
    source: '@uid'

However, this fails, so profile_id is null.

Do you happen to know, how can I use entity_lookup (or another) plugin for this?

EDIT: It looks like this might be a Drupal Core issue. I debugged the code of EntityLookup.php plugin and printed the actual DB query generated from the entity query:

SELECT base_table.revision_id AS revision_id, base_table.profile_id AS profile_id
FROM profile base_table
         INNER JOIN profile profile ON profile.profile_id = base_table.profile_id
WHERE (profile.uid = '153')
  AND (profile.type = 'profile')

This works fine and return following result when used directly against MySQL server:

revision_id profile_id
87 87

However, $query->execute() still returns an empty array. Why?

EDIT: It looks like this might be a bug: https://www.drupal.org/project/migrate_plus/issues/3230477

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.