public function OrderProduct::query in Commerce Migrate 8.2
Same name and namespace in other branches
- 3.1.x modules/ubercart/src/Plugin/migrate/source/OrderProduct.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\OrderProduct::query()
- 3.0.x modules/ubercart/src/Plugin/migrate/source/OrderProduct.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\OrderProduct::query()
Return value
\Drupal\Core\Database\Query\SelectInterface
Overrides SqlBase::query
File
- modules/
ubercart/ src/ Plugin/ migrate/ source/ OrderProduct.php, line 21
Class
- OrderProduct
- Ubercart order product source.
Namespace
Drupal\commerce_migrate_ubercart\Plugin\migrate\sourceCode
public function query() {
$query = $this
->select('uc_order_products', 'uop')
->fields('uop', [
'order_product_id',
'order_id',
'nid',
'title',
'qty',
'price',
'data',
]);
$query
->innerJoin('uc_orders', 'uo', 'uop.order_id = uo.order_id');
// Ubercart 6 order products have no timestamps to match those on Commerce 2
// order items, so take them from the order.
$query
->fields('uo', [
'order_total',
'created',
'modified',
]);
$query
->orderBy('order_product_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;
}