diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-05-07 01:40:26 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-05-07 01:40:26 +0300 |
commit | b4907a004ceffb3fdcabd993b7cbc7866ddad4bc (patch) | |
tree | 55dc66373623153e674519c247f7419658847baa | |
parent | 8de16262ef3d6288daa08d7cb4a362718ec7e286 (diff) |
refs #7851 fix avg_order_revenue is not displayed in evolution graph
-rw-r--r-- | plugins/Goals/API.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php index 2cb2366c34..5a699fac60 100644 --- a/plugins/Goals/API.php +++ b/plugins/Goals/API.php @@ -365,7 +365,8 @@ class API extends \Piwik\Plugin\API 'date' => $date, 'idGoal' => $idGoal, 'columns' => $columns, - 'serialize' => '0' + 'serialize' => '0', + 'format_metrics' => '0' )); $tableSegmented->filter('Piwik\Plugins\Goals\DataTable\Filter\AppendNameToColumnNames', @@ -402,6 +403,14 @@ class API extends \Piwik\Plugin\API $allMetrics = Goals::getGoalColumns($idGoal); $requestedColumns = Piwik::getArrayFromApiParameter($columns); + $shouldAddAverageOrderRevenue = (in_array('avg_order_revenue', $requestedColumns) || empty($requestedColumns)) && $isEcommerceGoal; + + if ($shouldAddAverageOrderRevenue && !empty($requestedColumns)) { + $avgOrder = new AverageOrderRevenue(); + $metricsToAdd = $avgOrder->getDependentMetrics(); + $requestedColumns = array_unique(array_merge($requestedColumns, $metricsToAdd)); + } + $report = Report::factory('Goals', 'getMetrics'); $columnsToGet = $report->getMetricsRequiredForReport($allMetrics, $requestedColumns); @@ -420,12 +429,12 @@ class API extends \Piwik\Plugin\API // TODO: this should be in Goals/Get.php but it depends on idGoal parameter which isn't always in _GET (ie, // it's not in ProcessedReport.php). more refactoring must be done to report class before this can be // corrected. - if ((in_array('avg_order_revenue', $requestedColumns) - || empty($requestedColumns)) - && $isEcommerceGoal - ) { + if ($shouldAddAverageOrderRevenue) { $dataTable->filter(function (DataTable $table) { $extraProcessedMetrics = $table->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME); + if (empty($extraProcessedMetrics)) { + $extraProcessedMetrics = array(); + } $extraProcessedMetrics[] = new AverageOrderRevenue(); $table->setMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME, $extraProcessedMetrics); }); |