Skip to content
Extraits de code Groupes Projets
Valider 556e32e0 rédigé par Marcin Czołnowski's avatar Marcin Czołnowski
Parcourir les fichiers

Fix for ecommerce segmentation.

parent 0b87cc57
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -499,25 +499,6 @@ class LogAggregator ...@@ -499,25 +499,6 @@ class LogAggregator
*/ */
public function queryEcommerceItems($dimension) public function queryEcommerceItems($dimension)
{ {
$query = "SELECT
name as label,
" . self::getSqlRevenue('SUM(quantity * price)') . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_REVENUE . "`,
" . self::getSqlRevenue('SUM(quantity)') . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_QUANTITY . "`,
" . self::getSqlRevenue('SUM(price)') . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_PRICE . "`,
count(distinct idorder) as `" . Metrics::INDEX_ECOMMERCE_ORDERS . "`,
count(distinct idvisit) as `" . Metrics::INDEX_NB_VISITS . "`,
case idorder when '0' then " . GoalManager::IDGOAL_CART . " else " . GoalManager::IDGOAL_ORDER . " end as ecommerceType
FROM " . Common::prefixTable('log_conversion_item') . "
LEFT JOIN " . Common::prefixTable('log_action') . "
ON $dimension = idaction
WHERE server_time >= ?
AND server_time <= ?
AND idsite = ?
AND deleted = 0
GROUP BY ecommerceType, $dimension
ORDER BY null";
// Segment not supported yet
// $query = $this->query($select, $from, $where, $groupBy, $orderBy);
$select = array( $select = array(
"name as label", "name as label",
self::getSqlRevenue('SUM(quantity * price)') . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_REVENUE . "`", self::getSqlRevenue('SUM(quantity * price)') . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_REVENUE . "`",
...@@ -528,21 +509,19 @@ class LogAggregator ...@@ -528,21 +509,19 @@ class LogAggregator
"case idorder when '0' then " . GoalManager::IDGOAL_CART . " else " . GoalManager::IDGOAL_ORDER . " end as ecommerceType" "case idorder when '0' then " . GoalManager::IDGOAL_CART . " else " . GoalManager::IDGOAL_ORDER . " end as ecommerceType"
); );
$bind = $this->getBindDatetimeSite();
return $this->getDb()->query($query, $bind);
$from = array( $from = array(
"log_conversion_item", "log_conversion_item",
array( array(
"table" => "log_action", "table" => "log_action",
"joinOn" => sprintf("log_conversion_item.%s = log_action.idaction", $field) "joinOn" => sprintf("log_conversion_item.%s = log_action.idaction", $dimension)
), ),
array( array(
"table" => "log_visit", "table" => "log_visit",
"joinOn" => "log_conversion_item.idvisit = log_visit.idvisit" "joinOn" => "log_conversion_item.idvisit = log_visit.idvisit"
) )
); );
$where = " server_time >= ? AND server_time <= ? AND log_conversion_item.idsite = ? AND deleted = 0"; $where = "server_time >= ? AND server_time <= ? AND log_conversion_item.idsite = ? AND deleted = 0";
$groupBy = sprintf("ecommerceType, %s", $field); $groupBy = sprintf("ecommerceType, %s", $dimension);
$query = $this->generateQuery( $query = $this->generateQuery(
implode(", ", $select), implode(", ", $select),
......
...@@ -356,6 +356,8 @@ class Segment ...@@ -356,6 +356,8 @@ class Segment
if ($table == "log_conversion") { if ($table == "log_conversion") {
$joinWithSubSelect = true; $joinWithSubSelect = true;
} }
} elseif ($table === 'log_conversion_item') {
$join = "log_conversion_item.idvisit = log_visit.idvisit";
} else { } else {
throw new Exception("Table '$table', can't be joined for segmentation"); throw new Exception("Table '$table', can't be joined for segmentation");
} }
......
...@@ -375,7 +375,8 @@ class Archiver extends \Piwik\Plugin\Archiver ...@@ -375,7 +375,8 @@ class Archiver extends \Piwik\Plugin\Archiver
$dataTableToSum = $this->dimensionRecord; $dataTableToSum = $this->dimensionRecord;
foreach ($this->dimensionRecord as $recordName) { foreach ($this->dimensionRecord as $recordName) {
$dataTableToSum[] = self::getItemRecordNameAbandonedCart($recordName); $dataTableToSum[] = self::getItemRecordNameAbandonedCart($recordName);
$this->getProcessor()->aggregateDataTableReports($dataTableToSum); }
$this->getProcessor()->aggregateDataTableRecords($dataTableToSum);
/* /*
* Archive General Goal metrics * Archive General Goal metrics
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter