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.
It would be great to be able to add parents when import terms (thereby creating hierarchical terms).
Comment | File | Size | Author |
---|---|---|---|
#15 | feeds-term-parent-1004668-15.patch | 3.34 KB | morten_kroyer |
#1 | term_parent_1004668_1_head.patch | 3.25 KB | joshuajabbour |
#1 | term_parent_1004668_1_guid.patch | 3.36 KB | joshuajabbour |
Comments
Comment #1
joshuajabbour CreditAttribution: joshuajabbour commentedAnd here are two patches to do just that. Parent terms can be matched on term id, term name, feeds guid, or feeds url.
The patches contain the same fixes -- the first is against 6.x head, the second applies after #980212: Support guid/url for taxonomy term importer.
Comment #2
joshuajabbour CreditAttribution: joshuajabbour commentedComment #3
David Goode CreditAttribution: David Goode commentedLooks good, seems to work, but it'd be nice to support parental relationships between terms in the same import that isn't contingent on the order in which they appear in the CSV or RSS file. Might need some sort of memory to achieve this. Or, could just hack it and automatically import twice and update terms...that wouldn't be very nice though.
IE, for something like terms.csv:
"Term", "Parent"
a, b
b, --
This won't work.
Comment #4
joshuajabbour CreditAttribution: joshuajabbour commentedYes, the parent terms must exist. While not perfect, I think that's pretty standard, as you can't reference something that doesn't exist.
Drupal behaves like this currently. Parent terms have to exist in order to be referenced (same with nodereferences). Not sure that imports should work differently.
IMO, what you're describing is an advanced behavior and could always be added later (however I believe it's fairly non-trivial). But the current patch does the actual mapping correctly.
Comment #5
beeradb CreditAttribution: beeradb commentedI think this is a good starting point for dependent terms. Importing terms (or anything) which requires dependent sets is non trivial. Every importer I've worked with has had the requirement on the developer to either correctly weight their import sets (in the case of something like migrate.module) or just structure their import files so the content which is depended upon comes before the dependent. I think this is a reasonable expectation to put on Developers, and is certainly an improvement over not having the ability to import parent terms.
Comment #6
David Goode CreditAttribution: David Goode commentedGood points, looks good in that context, although it might be nice to add some documentation or description of this behavior later for more novice users. Thanks.
Comment #7
philipz CreditAttribution: philipz commentedIs someone trying to implement this for D7 version?Ok I see this is hidden right now and after adding
to getMappingTargets function I importet child terms. They got messed up because ids are not the same but it's a step forward.
Comment #8
rickmanelius CreditAttribution: rickmanelius commentedI agree with beeradb and David Goode, it should be the responsibility of the data being imported to ensure the parent data already exists. Otherwise feeds would have to do some preprocessing to properly order the file (awesome, but I'm not sure anyone is gung ho to put that in right now).
What is the status of this patch? I see reviewed and tested by the community, but I didn't see the patch code in the latest dev for 6.x.
I'm asking because I'm very interested in this functionality for the same functionality in Drupal 7 (see current feature request ticket #1159628: How do you import a hierarchical taxonomy with feeds? for feeds-7.x-2.0-dev. My goal being importing 1 level of parent child nodes.
Comment #9
rickmanelius CreditAttribution: rickmanelius commentedThis patch here also works, and adds in the ability to set the taxonomy weight as well.
#1152940: Feeds term import with hierarchy and weight.
I tested it and it works. I wonder which of these is the better solution?
Comment #10
Dave ReidThis also needs tests, and to be patched for 7.x first.
Comment #11
rickmanelius CreditAttribution: rickmanelius commented@Dave Reid,
#1152940: Feeds term import with hierarchy and weight is against 7.x and these patches appear to duplicate functionality. Should we simply close this one and use the other?
Comment #12
janusman CreditAttribution: janusman commentedMaybe this is unrelated, but, is content_taxonomy mapping from the parent feed node working (on D6 branch?)
Comment #13
divined CreditAttribution: divined commentedHow to save deepest term from all hierarchy?
I have the following structure:
Parent1
--Child1 //here a problem
--Child2
--Child3
Parent2
--Child1 //here a problem
--Child4
--Child5
Comment #14
David_Rothstein CreditAttribution: David_Rothstein commentedThis sounds somewhat related to the following issue in the Feeds Tamper module: #1319278: Support automatic importing of the term hierarchy for nested taxonomy terms
Comment #15
morten_kroyer CreditAttribution: morten_kroyer commentedPatch from #1 ported to work against current stage dev.
Also work with 6.x-1.0-beta13 release.
Comment #16
twistor CreditAttribution: twistor commentedComment #18
MegaChriz CreditAttribution: MegaChriz commentedSee also:
Comment #19
twistor CreditAttribution: twistor commented