Maybe this has been discussed before, but i can't find any reference, so i decided to post this as new request.

I'm trying to import a taxonomy terms list from an old website to a new one, using a csv file - it's a simple list as:

tid,term
12,"term 1"
13,"term 2"
etc.

I would like that in the "target" vocabulary, each term.id is the same as in the source (i want "term 1" as $tid->12, "term 2" ad $tid=13, etc.). But I cant find a way to map the "tid" from the csv file, to the proper term.id. Each term is created in the vocabulary as a new one, with a new, different term id.

Is this just *possible*? :)

Thanks

fb

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AvalancheOfLlamas’s picture

I'm looking for this functionality as well. When taxonomy terms have non-unique names, it makes it difficult to update them. I'd add to the use case above that I have:

tid,term,CCK text field
12,"Contact Name A","Company 1"
13,"Contact Name B","Company 2"
14,"Contact Name B","Company 3"

tl;dr: I'm trying to make an importer to update taxonomy terms, but it's impossible without the TID, since I have deliberately duplicated term names.

twistor’s picture

Component: Feeds Import » Code
Status: Active » Fixed

The taxonomy module will not let you assign a tid to a term that doesn't not exist. The node module will allow this, which is why we provide that functionality for node.

What you're really looking for is a unique value to map to. Simply map the value you wanted to use for tid to the GUID target and set it as unique, that will accomplish basically the same thing.

francoud’s picture

thanks Twistor. It's exactly what i did and it worked ;-)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

brtamas’s picture

Here is a patch for feeds 2.0-beta. It is not a nice solution, but works.

pelicani’s picture

Thank you brtamas!
It is a very nice solution.
I like how you used the existing taxonomy query to validate that the term getting imported is new, rather than just relying on the existence of a tid.
Slick.
The patch installed cleanly.

peace,
michael

pelicani’s picture

Status: Closed (fixed) » Needs review

I feel this would be beneficial to others.
I'm working on a project and the dev before me couldn't get the tids to import.
When using taxonomy references we need to keep the tid intact.
Your solution work well.
Can this patch get a review?
Please and thank you.

peace,
mcihael

MegaChriz’s picture

Category: Support request » Feature request
Status: Needs review » Needs work
Issue tags: +Needs tests

It would be nice if this could get implemented in a similar way as #1570544: Add UID target to FeedsUserProcesser. (if possible). The function taxonomy_term_save_new_with_tid() seems to duplicate a lot of what the taxonomy module is already doing. Is there a way to avoid that?

It would also need tests. These tests could be implemented in a similar way as FeedsCSVtoUsersTest::testUidTarget() and FeedsCSVtoUsersTest::testUidUpdating().

masher’s picture

Patch #5 worked perfectly for me.

Some duplicate term id error messages in the feed log but terms ID assigned correctly

Many thanks

MegaChriz’s picture

NWOM’s picture

#5 still works amazingly. Otherwise terms cannot import if the Term ID is being targeted. Oddly it says that the items were successfully imported even though they aren't created. This patch fixes this.