0

I using feeds module for import data from xml to node.

I have XML:

<root> 
<item>
<title>Example 1</title> <!-- map to node title-->
<body>Body of example 1</body> <!-- map to node title-->
<term_name>My_term</term_name>
<term_tid>15</term_tid>
</item>
</root>
SELECT tid, vid, name FROM term_data;
tid vid name
15  19  My_term

If I map <term_name> to my node taxonomy term (and term name exist) its working.
But If i map <term_tid> to my node taxonomy term (and term tid exist) it's NOT working. Why?

Thanks for helping

0

2 Answers 2

0

before importing nodes from a site that contains taxonomy terms , try first to import all taxonomy terms ( you can use taxonomy manager ).

Feeds will add a term with a new tid if It not exist , not the same as tid of the site from where you export

1
  • All taxonomy term that i need exists. And I dont add new term by feeds (if doens't exist). I what map taxonomy term by nid
    – kubedan
    Mar 28, 2012 at 14:45
0

I solve for category_tid:

function my_module_feeds_after_parse(FeedsImporter $importer, FeedsSource $source) {
if ($source != null && $source->id == 'import_my_module') {  
  $vid = 19 //id of vocabulary
    foreach ($source->batch->items as & $item) {
      if (($category = db_fetch_object(db_query("SELECT tid, vid, name, description FROM {term_data} WHERE tid= %d AND vid = %d", $item['<term_tid>'], $vid))) !== FALSE) {
        $item['<term_tid>'] = new FeedsTermElement($category);
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.