data_taxonomy_data_insert() and data_taxonomy_data_update() expect that the tids for terms are being passed, but Feeds passes term names when mapping from Categories. As a result, each tid that is saved is set to 0. This also does not allow for free tagging when items have unknown Category names.

In contrast, taxonomy_feeds_set_target() in Feeds taxonomy.inc (which handles mapping for nodes) expects term names and then converts to tids or lets core taxonomy handle free tagging.

Since categories are the most obvious source for mapping taxonomy data in feed items, data_taxonomy should check (at least when mapping) whether the terms being passed are tids or term names and convert them to tids if necessary. This would support feed Categories and sources from other modules like Extractor. Support for free tagging would also be nice.

Great work on all of these modules, by the way!

Comments

alex_b’s picture

We could make _update and _insert smarter and look up a term if the passed in identifier is a string.

kc1981’s picture

Changing the foreach() loop in _insert() beginning on line 85 to something like the following seems to work well for new items:

        foreach ($record['data_taxonomy:'. $vid] as $tid) {
          if (!is_numeric($tid)) {
            if ($term_found = taxonomy_get_term_by_name($tid)) {
              $tid = $term_found[0]->tid;
            }
            else {
              $tid = 0;
            }
          }
          if ($tid) {
            db_query("INSERT INTO {data_taxonomy}(id, data_table_name, tid) VALUES(%d, '%s', %d)", $id, $table_name, $tid);
          }
        }

The same change in the loop in _update(), however, has some issues, at least on my system. The proper value for $tid is produced, but only the last 2 records are inserted into data_taxonomy.