Hey guys,

First this module is an amazing piece of code. It's helping out quite a bit on a number of projects. So thanks.

I have a question that's mostly for style but would like know how you would handle it. Some style points, but this would provide a better script to my clients.

Say I have a client's table that looks like this:

s_id s_title is_published is_active is_shown
7 My Title 1 1 0
8 My second... 1 1 0
9 My third... 0 1 0
10 Gang gang dance 0 0 0

And for my site building purposes, I want to map those to a drupal taxonomy, not cck fields.

Or for a similar situation:

s_id s_title s_class
7 My Title 15
8 My second... 111
9 My third... 32
10 Gang gang dance 12

Now one way is that I could just create the taxonomy on the site, and have a map that maps the value to drupal tids. Then use prepareRow to swap these out when I import the content as nodes.

 $s_class_map = array( 
    15 => 7232, 
    32 => 
    'etc' => 'the rest'
  ...)

That works, but requires that I know what those TIDs are. It requires any manual action on a live site and a change to code. It also duplicates a lot of the work that Migrate does.

One approach that I am playing with now is creating a SQL query that creates the map. Something like

SELECT DISTINCT(s_class_name) FROM s_content_table;

I'm reading through the WineTerm classes, but I believe it all deals with a dedicated table.
Any comments? Thanks!

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

It's a little confusing, but I'm guessing s_class_name is what you want mapped to a taxonomy term name in Drupal? s_content_table contains rows corresponding to nodes? So, all you need to do in the node migration is

$this->addFieldMapping('field_term_reference', 's_class_name')
       ->arguments(array('create_term' => TRUE));

Then, as each node is imported, the class name from the source query is looked up in the vocabulary and if matching the tid is saved; if no match is found, the term is created and the new tid is saved.

Does that address your question?

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)