You are here

public function BillingProfile::query in Commerce Migrate 3.0.x

Same name and namespace in other branches
  1. 8.2 modules/commerce/src/Plugin/migrate/source/commerce1/BillingProfile.php \Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\BillingProfile::query()
  2. 3.1.x modules/commerce/src/Plugin/migrate/source/commerce1/BillingProfile.php \Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\BillingProfile::query()

Return value

\Drupal\Core\Database\Query\SelectInterface

Overrides SqlBase::query

File

modules/commerce/src/Plugin/migrate/source/commerce1/BillingProfile.php, line 52

Class

BillingProfile
Gets Commerce 1 commerce_customer_profile source from database.

Namespace

Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1

Code

public function query() {
  $query = $this
    ->select('commerce_customer_profile', 'cp')
    ->fields('cp')
    ->condition('cp.type', 'billing');

  /** @var \Drupal\Core\Database\Schema $db */
  if ($this
    ->getDatabase()
    ->schema()
    ->tableExists('commerce_addressbook_defaults')) {
    $query
      ->leftJoin('commerce_addressbook_defaults', 'cad', 'cp.profile_id = cad.profile_id AND cp.uid = cad.uid AND cp.type = cad.type');
    $query
      ->addField('cad', 'type', 'cad_type');
  }
  return $query;
}