3 namespace Drupal\migrate_example_advanced\Plugin\migrate\source;
5 use Drupal\migrate\Plugin\migrate\source\SqlBase;
8 * A straight-forward SQL-based source plugin, to retrieve category data from
15 class WineTerm extends SqlBase {
20 public function query() {
21 return $this->select('migrate_example_advanced_categories', 'wc')
22 ->fields('wc', ['categoryid', 'type', 'name', 'details', 'category_parent', 'ordering'])
23 // This sort assures that parents are saved before children.
24 ->orderBy('category_parent', 'ASC');
30 public function fields() {
32 'categoryid' => $this->t('Unique ID of the category'),
33 'type' => $this->t('Category type corresponding to Drupal vocabularies'),
34 'name' => $this->t('Category name'),
35 'details' => $this->t('Description of the category'),
36 'category_parent' => $this->t('ID of the parent category'),
37 'ordering' => $this->t('Order in which to display this category'),
46 public function getIds() {
47 return ['categoryid' => ['type' => 'integer']];