I have a taxonomy like the following:

A
- A1
- A2
B
- B1
- A1

If i want to import a node, with the term "A1", there will be problem. Is there any way to import it as B->A1 or A->A1?

Thanks

Comments

derekw’s picture

Same challenge here. Any progress?

David_Rothstein’s picture

There's a patch for the Feeds Tamper module that might help with that: #1319278: Support automatic importing of the term hierarchy for nested taxonomy terms

pandaski’s picture

We are using the content taxonomy filed, and met the same issue.

Our solution is:

add the query once the term is given by a number;

However, the potential issue is if the term itself is a number.

/**
 * Try to map a string to an existing term by name and vocabulary id.
 *
 * Provides a case-insensitive and trimmed mapping, to maximize the
 * likelihood of a successful match limited by a vocabulary id.
 *
 * @param $name
 *   Name of the term to search for.
 *
 * @param $vid
 *   The vocabulary's ID.
 *
 * @return
 *   An array of matching term objects.
 * @package 
 *   add the support for term id; however, once the term name is number, maybe cause some issues.
 */
function content_taxonomy_get_term_by_name_vid($name, $vid) {
	if (is_numeric($name)) {
		$db_result = db_query(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE t.tid = '%d' AND vid=%d", 't', 'tid'), $name, $vid);
	}
	elseif (is_string($name)) {
  	$db_result = db_query(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE LOWER(t.name) = LOWER('%s') AND vid=%d", 't', 'tid'), trim($name), $vid);
	}
  $result = array();
  while ($term = db_fetch_array($db_result)) {
    $result[] = $term;
  }
  return $result;
}
algazaras’s picture

Could you elaborate your answer? I have this same problem with duplicate terms but I don't exactly understand what have you done.
I think it may be a solution to use the Content Taxonomy module, as you propose, and change the parent property of the content type every time I import nodes, but I have yet to try this approach.

algazaras’s picture

Issue summary: View changes

Fix

twistor’s picture

Component: Feeds Import » Code
Issue summary: View changes
Status: Active » Closed (outdated)