Hello,

I've found small issue - feedapi_mapper_taxonomy.inc mapper do not respect terms synonyms. My typical workflow is following:
- I am importing content from feeds and map value to Category vocabulary.
- taxonomy mapper creates new terms
- some terms later are merged with help of Taxonomy Manager module and all these terms added as synonyms. This usefull for, for example, different spellings, mispells, etc.

What happend next - next time if same misspelled term found in feed - module creates new term instead using one via synonyms.

Here is simple patch to make it look into synonyms prior creating new term:

feedapi_mapper_taxonomy.inc (line #64):

instead:

      else {
        if ($static == FALSE) {
          $new_term['name'] = $term;
          $new_term['vid'] = $vid;
          taxonomy_save_term($new_term);
          $tids[$new_term['tid']] = taxonomy_get_term($new_term['tid']);
          unset($new_term);
        }
      }

place:

      else {
        $curr_term = taxonomy_get_synonym_root($term);
        if ( is_object($curr_term) && $curr_term->vid == $vid ) {
          $tids[$curr_term->tid] = $curr_term;
        }
        else {
          if ($static == FALSE) {
            $new_term['name'] = $term;
            $new_term['vid'] = $vid;
            taxonomy_save_term($new_term);
            $tids[$new_term['tid']] = taxonomy_get_term($new_term['tid']);
            unset($new_term);
          }
        }
      }

unified patch attached.

CommentFileSizeAuthor
feedapi_mapper_taxonomy.inc_.patch815 bytespavel.karoukin

Comments

ekes’s picture

Respecting synonyms isn't really default Drupal behaviour - even if the obvious one. I've used http://drupal.org/project/synonym_collapsing to do this (including with FeedAPI Mapper)

pavel.karoukin’s picture

I am sure this should be implemented into module, 'cos when importing third-party categories you can't to be sure they will use correct spelling.

alex_b’s picture

Version: 6.x-1.0-beta9 » 6.x-1.x-dev
Status: Patch (to be ported) » Needs review

I actually think that this would be sane default behavior. Does this patch conflict with #354657: Taxonomy mapper: fix and simplify term creation ?