You are here

public function OrderPayment::query in Commerce Migrate 8.2

Same name and namespace in other branches
  1. 3.1.x modules/ubercart/src/Plugin/migrate/source/OrderPayment.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\OrderPayment::query()
  2. 3.0.x modules/ubercart/src/Plugin/migrate/source/OrderPayment.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\OrderPayment::query()

Return value

\Drupal\Core\Database\Query\SelectInterface

Overrides SqlBase::query

File

modules/ubercart/src/Plugin/migrate/source/OrderPayment.php, line 21

Class

OrderPayment
Provides migration source for orders.

Namespace

Drupal\commerce_migrate_ubercart\Plugin\migrate\source

Code

public function query() {
  $query = $this
    ->select('uc_payment_receipts', 'upr')
    ->fields('upr');
  $query
    ->innerJoin('uc_orders', 'uo', 'upr.order_id = uo.order_id');
  $query
    ->orderBy('received');
  $query
    ->orderBy('receipt_id');

  /** @var \Drupal\Core\Database\Schema $db */
  if ($this
    ->getDatabase()
    ->schema()
    ->fieldExists('uc_orders', 'currency')) {

    // Currency column is in the source.
    $query
      ->addField('uo', 'currency');
  }
  else {

    // If the currency column does not exist, add it as an expression to
    // normalize the query results.
    $currency_code = $this
      ->variableGet('uc_currency_code', 'USD');
    $query
      ->addExpression(':currency_code', 'currency', [
      ':currency_code' => $currency_code,
    ]);
  }
  return $query;
}