I'm importing about 1M nodes from a CSV file which contains a category field. This field contains taxonomy paths from a different system, such as "Social Sciences and the Law/Law/Family Law". What I need to do is examine that field and map it to an existing term in my Drupal database, and tag the new destination node appropriately.

What's the best way to accomplish this?

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

I've seen this scenario frequently (typically reorganizing a "channels" vocabulary), I approach it like this:

  $this->addFieldMapping('field_my_vocab', 'legacy_category');
...
  public function prepareRow($row) {
    $term_map = array(
      'Social Sciences and the Law/Law/Family Law' => 'New law term',
      'Top category/subcategory/subsubcategory' => 'New misc term',
    );
    $row->legacy_category = $term_map[$row->legacy_category];
  }

If you have too many categories to be comfortable with a PHP array, you can put them in a MySQL table and look up against that.

Is this helpful?

ebeyrent’s picture

BRILLIANT!!!

It was the prepareRow() method that I was missing - thanks a ton for the assistance!!

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Fixed

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