Returns the ID of the site a table is related to based on the 'site' metadata entry,
or null if there is none.
public static getSiteIdFromMetadata ( |
||
$table | ||
return | integer | null |
public function beforeFormat($report, DataTable $table) { $this->idSite = DataTableFactory::getSiteIdFromMetadata($table); return !empty($this->idSite); // skip formatting if there is no site to get currency info from }
/** * Adds the processed metrics. See {@link AddColumnsProcessedMetrics} for * more information. * * @param DataTable $table */ public function filter($table) { // Add standard processed metrics parent::filter($table); $goals = $this->getGoalsInTable($table); if (!empty($this->goalsToProcess)) { $goals = array_unique(array_merge($goals, $this->goalsToProcess)); sort($goals); } $idSite = DataTableFactory::getSiteIdFromMetadata($table); $extraProcessedMetrics = $table->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME); $extraProcessedMetrics[] = new RevenuePerVisit(); if ($this->processOnlyIdGoal != self::GOALS_MINIMAL_REPORT) { foreach ($goals as $idGoal) { if (($this->processOnlyIdGoal > self::GOALS_FULL_TABLE || $this->isEcommerce) && $this->processOnlyIdGoal != $idGoal) { continue; } $extraProcessedMetrics[] = new ConversionRate($idSite, $idGoal); // PerGoal\ConversionRate // When the table is displayed by clicking on the flag icon, we only display the columns // Visits, Conversions, Per goal conversion rate, Revenue if ($this->processOnlyIdGoal == self::GOALS_OVERVIEW) { continue; } $extraProcessedMetrics[] = new Conversions($idSite, $idGoal); // PerGoal\Conversions or GoalSpecific\ $extraProcessedMetrics[] = new GoalSpecificRevenuePerVisit($idSite, $idGoal); // PerGoal\Revenue $extraProcessedMetrics[] = new Revenue($idSite, $idGoal); // PerGoal\Revenue if ($this->isEcommerce) { $extraProcessedMetrics[] = new AverageOrderRevenue($idSite, $idGoal); $extraProcessedMetrics[] = new ItemsCount($idSite, $idGoal); } } } $table->setMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME, $extraProcessedMetrics); }