Problem/Motivation
It should be possible to do an entity lookup on sub-fields using value_key: field_name.subfield
.
In my particular example, but it might be valid for others too, I have the media field field_bridtv (from module
bridtv β
) and want to do an entity lookup on video_id, to get the target_id of the media entity (as all related media already exist, imported by the module and not by a migration).
The process part looks like:
field_bridtv_reference:
- plugin: skip_on_empty
method: process
source: field_bridtv_reference
- plugin: sub_process
process:
target_id:
- plugin: entity_lookup
source: field_bridtv_video_id
entity_type: media
bundle: bridtv
value_key: field_bridtv.video_id
Looking at the result in \Drupal\migrate_plus\Plugin\migrate\process\EntityLookup::query()
looks good, but then it fails on $entity->get($this->lookupValueKey), due to ContentEntityBase.php line 587, saying:
Field field_bridtv.video_id is unknown.
Steps to reproduce
I guess it could be reproduced with any field that has subfields.
Proposed resolution
The problem is with $entity->get($this->lookupValueKey)
, which in above example would be the same as $entity->get('field_bridtv.video_id')
. That does not work, instead it might look like $entity->get('field_bridtv')->video_id
.
Workaround
It might already work for many cases, setting ignore_case: true
. That way the code block resulting in the error won't be executed.