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.
With the taxonomy reference field removed (see change record https://www.drupal.org/node/2456869), the FeedsTarget "taxonomy" no longer can be used. As a result, the option "autocreate" is gone for taxonomy references and the test \Drupal\feeds\Tests\Feeds\RssNodeImport fails.
To fix this problem, somehow the FeedsTarget "taxonomy" should be used for when the target type of the entity reference field is "taxonomy_term". In other cases the FeedsTarget "entity_reference" should be used for entity reference fields.
A first patch will follow.
Comment | File | Size | Author |
---|---|---|---|
#1 | feeds-taxonomy-mapper-2476115-1.patch | 4.04 KB | MegaChriz |
Comments
Comment #1
MegaChriz CreditAttribution: MegaChriz commentedI've now tried to fix this problem by setting the FeedsTarget "taxonomy" field type to "entity_reference". This initially caused that this FeedsTarget got used for all entity reference fields. To fix this, I overrided the method
targets()
to return only targets when the field's target type is "taxonomy_term".This doesn't look like the best solution, because first the FeedsTarget "entity_reference" will register targets for all fields of type "entity_reference" and later on the FeedsTarget "taxonomy" will override the targets for fields that reference taxonomy terms, but only because "Taxonomy" is later in the alphabet than "EntityReference". I can imagine that contributed modules specifying their own entity type, sometimes want to provide specific options for referencing entities as well. Is there a better method of overriding already defined targets by an other FeedsTarget?
Details of the changes in the patch and their reasoning:
getBundle()
is changed intogetBundles
, because entitiy references now can target multiple bundles.Comment #2
twistor CreditAttribution: twistor commentedCould we just move the auto creation to the entity reference target and remove the taxonomy target?
Comment #4
twistor CreditAttribution: twistor commentedComment #6
MegaChriz CreditAttribution: MegaChriz commented@twistor
The auto creation will not work for every entity type, because some entities may require more values than just the label.
Leaving state to "needs work" for now. Feel free to set the issue back to "fixed" if the concern above does not apply. I haven't tested the module yet with the latest changes.
Comment #7
MegaChriz CreditAttribution: MegaChriz commentedComment #8
twistor CreditAttribution: twistor commented