Situation: Using a TAXONOMY_CSV_FORMAT_DEFINITION_LINKS import
Sample csv:
Tax|Tax|Topics & Keywords|||0|0|0|0
Banking|Banking|Topics & Keywords|||0|1|0|0|Tax
You have imported it once already and you reimport it (you can imagine some modification in other terms)
Possible bug:
While importing an existing term
// Import main term.
$current_result = taxonomy_csv_term_import($term, $options['existing_items']);
// Complete the term with the term id in case it's not been fulled.
$term->tid = $current_result['tid'];
// Save with name if identifiant was not set (else, it's already saved).
if ($line[1] == '') {
$result['name']['term'][$line[0]] = $current_result['name'];
$result['tid']['term'][$line[0]] = $current_result['tid'];
}
$result['msg'] = array_merge($result['msg'], $current_result['msg']);if the term id is set then it's not added to the $result array. Afterwards the second term can't find the parent in the result array and it's added twice....
Two options:
1) add it to the result array whre it try to preimport a term
or
2) Modify step 7: Import each parent and check result.
if (isset($result['name']['term'][$line[1]])) {
$term->tid = $result['tid']['term'][$line[1]];
}
// Pre-import is needed only when name and identifiant are different.
else {//if (drupal_strtolower($line[0]) != drupal_strtolower($line[1])) {
$current_result = taxonomy_csv_term_import(
(object) array(
'name' => $term->name,
'vid' => $term->vid,
),
TAXONOMY_CSV_EXISTING_IGNORE_CREATE);
$result['name']['term'][$line[1]] = $current_result['name'];
$result['tid']['term'][$line[1]] = $current_result['tid'];
$result['msg'] = array_merge($result['msg'], $current_result['msg']);
if (_taxonomy_csv_worst_message($current_result['msg']) < TAXONOMY_CSV_PROCESS_NOTICE) {
break;
}
$term->tid = $current_result['tid'];
}Why only import it if the name and the identifiant are different? That makes that if they are the same and it was imported already it isn't load in the $result array.
So... would be the solution exchange this code for...
// Pre-import is needed only when name and identifiant are different.
else {
$current_result = taxonomy_csv_term_import(
Comments
Comment #1
jordim commentedThe solution isn't good.......
TAXONOMY_CSV_EXISTING_IGNORE_CREATE creates the term again..... Should have to thing in another solution
Comment #2
jordim commentedSolved in my case exchanging the step 7 of the function
TAXONOMY_CSV_EXISTING_IGNORE_CREATE => $options["existing_items"]);
Comment #3
Daniel_KM commentedHi,
Your patch of step 7 has been committed.
Thanks for all your comments.
Sincerely,
Daniel Berthereau
Infodoc & Knowledge management