If you have a term importer with a source that can set multiple parents to a single term you may want to use multiple columns as "Parent: term name". But his will result in errors if you have rows that don't have all parent rows fill (some terms have only 1 parent, some have 2, some have 3) because feeds will try to insert the same key multiple times to the term_hierarchy table (term_id and parent ID as 0 multiple times).

On my case the solution is just to eliminate this lines from FeedsTermProcessor.inc

--- a/plugins/FeedsTermProcessor.inc
+++ b/plugins/FeedsTermProcessor.inc
@@ -134,12 +134,6 @@ class FeedsTermProcessor extends FeedsProcessor {
           if (!empty($parent_tid)) {
             $target_term->parent[] = $parent_tid;
           }
-          else {
-            $target_term->parent[] = 0;
-          }
-        }
-        else {
-          $target_term->parent[] = 0;
         }
         break;
       case 'parentguid':

Because if you are setting the parent for a term you almost always don't need to set any missing parents as 0.

CommentFileSizeAuthor
#2 feeds-missing_parents-1822484-2.patch590 bytesmsti

Comments

twistor’s picture

Issue summary: View changes
Status: Needs review » Needs work

A patch would be helpful.

msti’s picture

Version: 7.x-2.0-alpha7 » 7.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new590 bytes

Patch added against branch 7.x-2.x

Status: Needs review » Needs work

The last submitted patch, 2: feeds-missing_parents-1822484-2.patch, failed testing.

msti’s picture

Status: Needs work » Needs review
twistor’s picture

Status: Needs review » Needs work

The last submitted patch, 2: feeds-missing_parents-1822484-2.patch, failed testing.

bluegeek9’s picture

Status: Needs work » Closed (outdated)

Drupal 7 reached end of life and the D7 version of Feeds is no longer being developed. To keep the issue queue focused on supported versions, we’re closing older D7 issues.

If you still have questions about using Feeds on Drupal 7, feel free to ask. While we won’t fix D7 bugs anymore, we’re happy to offer guidance to help you move forward. You can do so by opening (or reopening) a D7 issue, or by reaching out in the #feeds channel on Drupal Slack.

If this issue is still relevant for Drupal 10+, please open a follow-up issue or merge request with proposed changes. Contributions are always welcome!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.