Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The core migrate lookup process plugin always returns an entity ID.
However, references from config entities that point to content entities use UUIDs. For example, a Commerce condition on the store entity.
Comment | File | Size | Author |
---|---|---|---|
#10 | migrate_plus-2974221-10-Add-a-EntityValue-process-plugin.patch | 11.49 KB | maks9889 |
Comments
Comment #2
joachim CreditAttribution: joachim at Torchbox commentedComment #4
heddnClosing #2926200: Add process plugin for loading values from existing entities as duplicate to here..
Can we remove this option and just return the whole field? If we need to cherry-pick specific values, we can use extract process plugin.
Can we move all this to the constructor and return a BadPluginDefinitionException instead of migration exception?
And check the entity type is a valid entity type in the constructor and return an InvalidArgumentException if it isn't? This also in constructor.
I like this! I forgot to ask for that in the other issue. This is great.
Comment #5
heddnAlso, needs tests.
Comment #6
esolitosShould this maybe be based on the entity lookup plugin? I mean, the difference could be very small and we could share most of the code I believe.
Comment #7
joachim CreditAttribution: joachim as a volunteer commentedI think they’re best kept separate.
The entity lookup plugin has variable input parameters, and a simple output.
This entity value plugin has a simple input, and variable output.
Combining them seems like it will increase complexity and make testing and usage harder.
It’s simple to chain them together.
Comment #8
geek-merlinFollowing the unix phliosophy of doing just one thing well, i'd propose that related issue.
Comment #9
geek-merlinMuch improved work in the other issue.
Comment #10
maks9889 CreditAttribution: maks9889 as a volunteer commentedI have updated the patch with code from "#3018849: Add a LoadEntity process plugin" but with loading concrete field.
Comment #11
maks9889 CreditAttribution: maks9889 as a volunteer commentedtests are now in the patch
Comment #12
geek-merlinI'm actively working with the patch from the other issue and think it obsoletes this one.
Comment #13
oldspot CreditAttribution: oldspot at Zoocha commentedI can see the other issue has the status "Closed (won't fix)" now so I've used the patch in this issue. I can confirm I can extract the field value correctly from the loaded entity.
In my case I combined it with a 'migration_lookup' plugin where I had to extract the 'fid' (file id) of a previously migrated Media entity and worked great:
Comment #14
joachim CreditAttribution: joachim at Factorial GmbH commentedThis works nicely with the entity_lookup plugin too.
I have a migration where I am creating new Media entities based on an image field on a content entity (and a subsequent migration will populate a new media reference field to point to the new Media entity).
To set the name field on the new Media entities, I am doing this:
Comment #15
Eduardo Morales AlbertiReally helpful, that's what I needed.
Comment #17
heddnThanks for your contributions.
Comment #19
marvil07 CreditAttribution: marvil07 at Adapt commentedThanks to all people involved here!
For reference, I closed a related gitlab issue #262: Retrieve a field from an existing entity, with a similar plugin.