You are here

public function BeerNode::query in Migrate Plus 8.2

Same name and namespace in other branches
  1. 8.5 migrate_example/src/Plugin/migrate/source/BeerNode.php \Drupal\migrate_example\Plugin\migrate\source\BeerNode::query()
  2. 8 migrate_example/src/Plugin/migrate/source/BeerNode.php \Drupal\migrate_example\Plugin\migrate\source\BeerNode::query()
  3. 8.3 migrate_example/src/Plugin/migrate/source/BeerNode.php \Drupal\migrate_example\Plugin\migrate\source\BeerNode::query()
  4. 8.4 migrate_example/src/Plugin/migrate/source/BeerNode.php \Drupal\migrate_example\Plugin\migrate\source\BeerNode::query()

Return value

\Drupal\Core\Database\Query\SelectInterface

Overrides SqlBase::query

File

migrate_example/src/Plugin/migrate/source/BeerNode.php, line 20

Class

BeerNode
Source plugin for beer content.

Namespace

Drupal\migrate_example\Plugin\migrate\source

Code

public function query() {

  /**
   * An important point to note is that your query *must* return a single row
   * for each item to be imported. Here we might be tempted to add a join to
   * migrate_example_beer_topic_node in our query, to pull in the
   * relationships to our categories. Doing this would cause the query to
   * return multiple rows for a given node, once per related value, thus
   * processing the same node multiple times, each time with only one of the
   * multiple values that should be imported. To avoid that, we simply query
   * the base node data here, and pull in the relationships in prepareRow()
   * below.
   */
  $query = $this
    ->select('migrate_example_beer_node', 'b')
    ->fields('b', [
    'bid',
    'name',
    'body',
    'excerpt',
    'aid',
    'countries',
    'image',
    'image_alt',
    'image_title',
    'image_description',
  ]);
  return $query;
}