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.
In the Drupal7 version it was possible to map to referenced entities using GUID and URL of the target item, this should be ported to 8.x version as well. I started working on this, it works but surely has issues too.
Drupal 7 entityreference was a contrib module that implemented entityreference_feeds_processor_targets_alter
hook to provide these mappings. Now that entityreference is in core Feeds should provide these as it does for other core entities too.
Comment | File | Size | Author |
---|---|---|---|
#17 | feeds-reference-by-guid-2788631-17.patch | 7.1 KB | juho-jaakkola |
#17 | interdiff-2788631-16-17.txt | 419 bytes | juho-jaakkola |
#16 | feeds-reference-by-guid-2788631-16.patch | 7.1 KB | mikran |
| |||
#16 | interdiff.txt | 1.22 KB | mikran |
#14 | interdiff-2788631-13-14.txt | 1.84 KB | MegaChriz |
Comments
Comment #2
Uhkis CreditAttribution: Uhkis at Mediamaisteri Oy commentedComment #3
Uhkis CreditAttribution: Uhkis at Mediamaisteri Oy commentedComment #4
Uhkis CreditAttribution: Uhkis at Mediamaisteri Oy commentedComment #5
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedThis is already possible, though maybe a bit harder to find. In the D8 version the target is called "Feeds item".
Comment #6
mikran CreditAttribution: mikran at Mediamaisteri Oy commentedOk, the issue title & description is bad, let me try to re-write that.
Comment #7
mikran CreditAttribution: mikran at Mediamaisteri Oy commentedAnd here is an image too. I've created one importer to import taxonomy terms and then when I'm configuring another importer to imports articles I have an option to map source id to taxonomy term via feeds item GUID.
Comment #8
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedAh, got it now. Yes, that would be an useful addition. And an essential one too, so bumping priority to major.
Comment #9
twistor CreditAttribution: twistor as a volunteer commentedI didn't do a full review, but this stood out.
Can this use entity query? We're trying very hard not to have any SQL specific code.
Comment #10
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedClosed #2861190: Add GUID & id() to Refference mapping settings as a duplicate which seems to be requesting the same feature (and it also has a patch).
Comment #11
mikran CreditAttribution: mikran at Mediamaisteri Oy commentedPatch rerolled & updated to work with latest version. I didn't fix the query mentioned in #9 yet though.
Comment #12
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedAccording to https://www.sitepoint.com/drupal-8-version-entityfieldquery/ it seems like something like the following could work? The EntityReference class gets the service 'entity.query' already injected.
Do you want to try that out, mikran?
Comment #13
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedLooked into this patch and I made the following changes:
findEntityByGuid()
now uses the injected query factory.get_class()
is removed. When we receive an object we should not just check its exact class but use "instanceof". Ideally, we should check if it is an instance of a certain interface. That is also what this patch does. It checks if the field is an instance of DataDefinitionInterface to ensure it has aisComputed()
method. FieldStorageDefinitionInterface doesn't extend DataDefinitionInterface so therefore the extra check.I noticed also that the call to
findEntityByGuid()
fails with the following fatal error when querying against an entity type that does not have a feeds_item field:So we should in that method first check if the entity type does have that field.
Setting to "Needs review" so that the testbot evaluates the patch, but the status should be "Needs work" because of the concern noted above.
Comment #14
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedThis fixes the concern noted in #13: before executing the entity query with a condition on the feeds_item field, first is checked if the target entity type has a feeds_item field.
Comment #15
juho-jaakkola CreditAttribution: juho-jaakkola at Mediamaisteri Oy commentedI'm not able to import anything with the latest patch (feeds-reference-by-guid-2788631-14.patch). Not yet sure why.
Comment #16
mikran CreditAttribution: mikran at Mediamaisteri Oy commentedSmall patch. I think this should fix the problem in #15.
FALSE
is a not valid value for entity_reference so usenull
as no value instead.Also I noticed that we don't have any test coverage at all for entity_reference target.
Comment #17
juho-jaakkola CreditAttribution: juho-jaakkola at Mediamaisteri Oy commentedThis fixes a misnamed variable in the patch number 16. I can confirm that with this fix the patch works as intended.
Green light from me for merging the patch with this fix.
Comment #18
PunamShelkeHI,
Patch No 17 is working for...
Comment #20
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedI have been using this patch for a while and did not notice any disruptiveness.
Committed #17.
Comment #22
scott.whittaker CreditAttribution: scott.whittaker as a volunteer commentedSorry to necro a closed issue, but how do you set this up? I've made an importer for a node type and then another importer for another node type which has entity reference fields from the first node type. I want to be able to use this to map fields to the nested entity reference via the importer I set up for that type, but I can't figure out how to set up the mappings.
I can get the interface shown in #5 from adding a "Feeds item" target, but can't get any further than that, I'm not even able to get an interface like that shown in #7.