You are here

protected function CommerceReportsBaseTestCase::createdProductsData in Commerce Reporting 7.4

Returns information about created products for tests.

Return value

array

1 call to CommerceReportsBaseTestCase::createdProductsData()
CommerceReportsViewsExportTestCase::testProductViewsDataExport in src/Tests/CommerceReportsViewsExportTestCase.php

File

src/Tests/CommerceReportsBaseTestCase.php, line 76

Class

CommerceReportsBaseTestCase
Class CommerceReportsBaseTestCase

Namespace

Drupal\commerce_reports\Tests

Code

protected function createdProductsData() {
  $products = array();
  foreach ($this->orders as $order) {
    foreach ($order['products'] as $product_id => $quantity) {
      $sku = $this->products[$product_id]->sku;
      if (empty($products[$sku])) {
        $products[$sku] = array(
          'quantity' => 0,
          'revenue' => 0,
        );
      }
      $products[$sku]['quantity'] += $quantity;
      $products[$sku]['revenue'] += $quantity * $this->products[$product_id]->commerce_price[LANGUAGE_NONE][0]['amount'];
    }
  }
  return $products;
}