Entity Lookup not working on nodes

Created on 20 September 2017, almost 7 years ago
Updated 8 August 2021, almost 3 years ago

I have a situation where I am using Migrate CSV to migrate multiple content-types from a single CSV file. I have everything configured so that I am able to import each of three content-types from the single CSV, but I need to be able to associate one content-type with another content-type using an Entity Reference field.

In a previous migration I set up these same content-types to associate with each other using the migration plugin when pulling from a non-Drupal database. That all worked fine.

But when pulling from the CSV file, I am able to use entity_lookup to associate the taxonomy_term, but not the proper node.

Here is what I have in my YML file:

field_content_ref_contact:
    plugin: entity_lookup
    source: contact_full_name
    ignore_case: true
    entity_type: node
    value_key: title
    bundle_key: type
    bundle: contact

I've also tried switching the bundle_key to vid. It's possible that it's not finding the contact_full_name in the system, but I'm not sure how to debug it to see.

I could probably get more information if I understood how to set up a migration source plugin and run prepareRow against the CSV file.

I haven't been able to find an example of entity_lookup being used for a node/entity_reference field. Just for taxonomies and users, so even an example of that would be helpful.

πŸ’¬ Support request
Status

Active

Version

4.0

Component

Examples

Created by

πŸ‡ΊπŸ‡ΈUnited States Topplestack Rural, Idaho

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.

  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    I'm hitting this as well -- I've debugged to find that the node lookup is successful, and it returns a double-array as the transformed value after finding the result. However, this does not successfully save in the entity reference.

    I tried expanding the definition using a sub_process to set the target_id directly, and didn't get it working at first -- but that's because I didn't map the source field in the sub_process. Once I did that, it's working fine! So this is how you do it -- map the target_id using a subprocess, along these lines:

      field_library:
        -
          plugin: sub_process
          source: field_library_name
          process:
            target_id:
              plugin: entity_generate
              source: value
              value_key: title
              default_values:
                status: 1
              values:
                uid: node_uid
                body: field_library_description
                field_library_type: field_library_type
                field_city: field_city
                field_state: field_state
    
Production build 0.69.0 2024