The import is not maintaining term hierarchy. Please check my code and see if this is what I am doing wrong or something in the migrate code

abstract class RTGTermMigration extends RTGMigration {
  public function __construct($type, $vocabulary_name, $description) {
    parent::__construct();
    $this->description = $description;
    
    $this->map = new MigrateSQLMap($this->machineName,
        array(
          'tid' => array('type' => 'int',
                                'unsigned' => TRUE,
                                'not null' => TRUE,
                                'alias' => 'vmt',
                               )
        ),
        MigrateDestinationTerm::getKeySchema()
      );

    $query = Database::getConnection('default', 'source_rtg')
            ->select('view_migrate_terms', 'vmt')
            ->fields('vmt', array('tid','vid','name', 'description', 'weight','parent'))
             ->condition('vid', $type)
             // This sort assures that parents are saved before children.
             ->orderBy('parent', 'ASC');
    $this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' =>FALSE));
    $this->destination = new MigrateDestinationTerm($vocabulary_name);

    // Mapped fields
    $this->addSimpleMappings(array('name','description','weight'));
    $this->addFieldMapping('parent', 'parent')
        ->sourceMigration($this->getMachineName());
//    $this->addFieldMapping('format')
//         ->defaultValue($this->basicFormat->format);

    // Unmapped source fields

    // Unmapped destination fields
    $this->addFieldMapping('parent_name')
         ->issueGroup(t('DNM'));
  }
}

The error I get is attached.
Thanks

CommentFileSizeAuthor
migrate_error.png187.79 KBrocket777

Comments

rocket777’s picture

Category: support » bug

Is "Taxonomy term hierarchy" not working a bug? if so, has it been fixed?
Thanks

mikeryan’s picture

Status: Active » Closed (duplicate)

This is a dupe of #1300258: Migrating nodes with multiple terms and vocs. Keeping that one open because it has more info.

mikeryan’s picture

Status: Closed (duplicate) » Active

My mistake - the symptoms are similar, but the other issue is about term references, this is about term parents...

mikeryan’s picture

Status: Active » Fixed

The difference between !isset() and empty() can be subtle, but sometimes important... Fixed!

Status: Fixed » Closed (fixed)

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

rlmumford’s picture

Status: Closed (fixed) » Active

I'm having the same problem with very similar code. How was this fixed?

mikeryan’s picture

It was fixed in a patch months ago. Term hierarchies are working fine for me - what precise problem are you seeing? Are you using 7.x-2.x-dev?

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)
mikeryan’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Long fixed.