You are here

public function PromotionReport::buildQuery in Commerce Reporting 8

Builds the aggregate query.

Report type plugins should add their field columns, aggregates, and groupBy statements here.

Parameters

\Drupal\Core\Entity\Query\QueryAggregateInterface $query: The aggregate query.

Overrides ReportTypeInterface::buildQuery

File

src/Plugin/Commerce/ReportType/PromotionReport.php, line 191

Class

PromotionReport
Provide a report for Promotions on behalf of commerce_promotion.

Namespace

Drupal\commerce_reports\Plugin\Commerce\ReportType

Code

public function buildQuery(QueryAggregateInterface $query) {
  $query
    ->aggregate('promotion_label', 'COUNT');
  $query
    ->aggregate('promotion_amount.number', 'SUM');
  $query
    ->aggregate('coupon_code', 'COUNT');
  $query
    ->aggregate('coupon_amount.number', 'SUM');
  $query
    ->groupBy('promotion_label');
  $query
    ->groupBy('coupon_code');
  $query
    ->groupBy('promotion_amount.currency_code');
}