Commit 73b3be1b authored by Reena Raghavan's avatar Reena Raghavan

Term.php File added (Taxonomy Term)

parent e37b46e1
id: article
label: Migrate Article
migration_group: my_custom_migrate
source_type: Database
source:
plugin: article
......@@ -13,7 +14,9 @@ destination:
process:
nid: nid
title: title
body: body_value
migration_dependencies:
required: {}
dependencies: {}
\ No newline at end of file
id: custom_taxonomy_term
label: Migrate taxonomy terms
migration_group: my_custom_migrate
source_type: Database
source:
plugin: custom_taxonomy_term
key: migrate
destination:
plugin: entity:taxonomy_term
default_bundle: tags
process:
tid: tid
vid:
plugin: migration_lookup
migration: custom_taxonomy_vocabulary
source: vid
name: name
description__value: description__value
weight: weight
parent_target_id:
-
plugin: migration_lookup
migration: custom_taxonomy_term
changed: timestamp
migration_dependencies:
required: {}
dependencies:
enforced:
module: {}
\ No newline at end of file
......@@ -26,8 +26,17 @@ class Article extends SqlBase
*/
public function query()
{
$query = $this->select('node_field_data', 'ar')
->fields('ar', ['nid','title']);
// $query = $this->select('node_field_data', 'ar')
// ->fields('ar', ['nid','title']);
// return $query;
$query = $this->select('node_field_data', 'ar');
$query->fields('ar', ['nid', 'title']);
$query->addField('nb', 'body_value');
$query->leftjoin('node__body', 'nb', 'ar.nid = nb.entity_id');
$query->condition('ar.type', 'article');
return $query;
......
<?php
/**
* @file
* Contains \Drupal\uvf_migrate\Plugin\migrate\source\Term.
*/
namespace Drupal\uvf_migrate\Plugin\migrate\source;
use Drupal\migrate\Row;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
/**
* Drupal 9 taxonomy terms source from database.
*
* @todo Support term_relation, term_synonym table if possible.
*
* @MigrateSource(
* id = "custom_taxonomy_term",
* source_provider = "taxonomy"
* )
*/
class Term extends SqlBase
{
/**
* {@inheritdoc}
*/
public function query()
{
$query = $this->select('taxonomy_term_field_data', 'td')
->fields('td', [
'tid',
'vid',
'name',
'description__value',
'weight'
]);
$query->addField('tp', 'parent_target_id');
$query->leftjoin('taxonomy_term__parent', 'tp', 'td.tid = tp.entity_id');
$query->distinct();
return $query;
}
/**
* {@inheritdoc}
*/
public function fields()
{
return [
'tid' => $this->t('The term ID.'),
'vid' => $this->t('Existing term VID'),
'name' => $this->t('The name of the term.'),
'description__value' => $this->t('The term description.'),
'weight' => $this->t('Weight'),
'parent_target_id' => $this->t("The Drupal term IDs of the term's parents."),
];
}
/**
* {@inheritdoc}
*/
public function getIds()
{
$ids['tid']['type'] = 'integer';
return $ids;
}
}
<?php
/**
* @file
* Contains \Drupal\uvf_migrate\Plugin\migrate\source\Vocabulary.
*/
namespace Drupal\uvf_migrate\Plugin\migrate\source;
use Drupal\migrate\Row;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
/**
* Drupal 9 vocabularies source from database.
*
* @MigrateSource(
* id = "custom_taxonomy_vocabulary",
* source_provider = "taxonomy"
* )
*/
class Vocabulary extends SqlBase
{
/**
* {@inheritdoc}
*/
public function query()
{
$query = $this->select('taxonomy_term_field_data', 'v')
->fields('v', ['tid','name','description__value','weight']);
return $query;
}
/**
* {@inheritdoc}
*/
public function fields()
{
return [
'tid' => $this->t('The vocabulary ID.'),
'name' => $this->t('The name of the vocabulary.'),
'description__value' => $this->t(
'The description of the vocabulary.'
),
'weight' => $this->t(
'The weight of the vocabulary in relation to other vocabularies.'
),
];
}
/**
* {@inheritdoc}
*/
public function getIds()
{
$ids['tid']['type'] = 'integer';
return $ids;
}
}
......@@ -10,7 +10,9 @@
*/
function uvf_migrate_uninstall() {
$configs = [
'migrate_plus.migration.article'
'migrate_plus.migration.article',
'migrate_plus.migration.custom_taxonomy_term',
'migrate_plus.migration.custom_taxonomy_vocabulary'
];
foreach($configs as $config){
$delete = \Drupal::database()->delete('config')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment