1

When doing a D6->8 migration, my taxonomy term migration template imports all the taxonomy terms found in the source D6 site into my specified D8 taxonomy.

How do I filter only the terms that belong to a specific vocabulary? For a D7 migration all I needed was:-

source:
  plugin: d7_taxonomy_term
  bundle: tags

Bundles are not part of D6 so is there a way to do this in the yml file? Like ...

source:
  plugin: d6_taxonomy_term
  ???

1 Answer 1

0

You could create a plugin, where you can use sql to query what you need.

For example:

<?php

namespace Drupal\custom_migration\Plugin\migrate\source;

use Drupal\migrate\Plugin\migrate\source\SqlBase;

/**
 * Minimalistic example for a SqlBase source plugin.
 *
 * @MigrateSource(
 *   id = "custom_vocab_plugin",
 *   source_module = "custom_module",
 * )
 */
class CustomVocabulary extends SqlBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = $this->select('vocabulary', 'v')
      ->fields('v', [
        [....] // YOUR SQL HERE
      ]);
    return $query;
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    return [
      [....]

    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids['vid']['type'] = 'integer';
    return $ids;
  }

}

Then you just need to use that plugin in your D6 migration:

source:
  plugin: custom_vocab_plugin

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.