Skip to content
Extraits de code Groupes Projets
Valider 01e8a05f rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

split ecommerce sales into sales and products

parent 8b5c4048
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -55,6 +55,39 @@ class Controller extends \Piwik\Plugins\Goals\Controller ...@@ -55,6 +55,39 @@ class Controller extends \Piwik\Plugins\Goals\Controller
return $this->ecommerceReport(); return $this->ecommerceReport();
} }
public function products()
{
$goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
$conversions = $goal['nb_conversions'];
$goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART);
$cartNbConversions = $goal['nb_conversions'];
$preloadAbandonedCart = $cartNbConversions !== false && $conversions == 0;
$goalReportsByDimension = new View\ReportsByDimension('Goals');
$ecommerceCustomParams = array();
if ($preloadAbandonedCart) {
$ecommerceCustomParams['abandonedCarts'] = '1';
} else {
$ecommerceCustomParams['abandonedCarts'] = '0';
}
$goalReportsByDimension->addReport(
'Goals_Products', 'Goals_ProductSKU', 'Goals.getItemsSku', $ecommerceCustomParams);
$goalReportsByDimension->addReport(
'Goals_Products', 'Goals_ProductName', 'Goals.getItemsName', $ecommerceCustomParams);
$goalReportsByDimension->addReport(
'Goals_Products', 'Goals_ProductCategory', 'Goals.getItemsCategory', $ecommerceCustomParams);
$view = new View('@Ecommerce/products');
$this->setGeneralVariablesView($view);
$view->productsByDimension = $goalReportsByDimension->render();
return $view->render();
}
public function sales() public function sales()
{ {
$viewOverview = $this->getGoalReportView(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER); $viewOverview = $this->getGoalReportView(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
......
...@@ -33,7 +33,8 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -33,7 +33,8 @@ class Menu extends \Piwik\Plugin\Menu
$menu->addItem('Goals_Ecommerce', '', $ecommerceUrl, 24); $menu->addItem('Goals_Ecommerce', '', $ecommerceUrl, 24);
$menu->addItem('Goals_Ecommerce', 'General_Overview', $ecommerceUrl, 1); $menu->addItem('Goals_Ecommerce', 'General_Overview', $ecommerceUrl, 1);
$menu->addItem('Goals_Ecommerce', 'Goals_EcommerceLog', $this->urlForAction('ecommerceLogReport'), 2); $menu->addItem('Goals_Ecommerce', 'Goals_EcommerceLog', $this->urlForAction('ecommerceLogReport'), 2);
$menu->addItem('Goals_Ecommerce', 'Ecommerce_Sales', $this->urlForAction('sales', $ecommerceParams), 3); $menu->addItem('Goals_Ecommerce', 'Goals_Products', $this->urlForAction('products', $ecommerceParams), 3);
$menu->addItem('Goals_Ecommerce', 'Ecommerce_Sales', $this->urlForAction('sales', $ecommerceParams), 4);
} }
} }
......
<h2 piwik-enriched-headline>{{ 'Goals_Products'|translate }}</h2>
{{ productsByDimension|raw }}
...@@ -436,13 +436,6 @@ class Controller extends \Piwik\Plugin\Controller ...@@ -436,13 +436,6 @@ class Controller extends \Piwik\Plugin\Controller
} else { } else {
$ecommerceCustomParams['abandonedCarts'] = '0'; $ecommerceCustomParams['abandonedCarts'] = '0';
} }
$goalReportsByDimension->addReport(
'Goals_Products', 'Goals_ProductSKU', 'Goals.getItemsSku', $ecommerceCustomParams);
$goalReportsByDimension->addReport(
'Goals_Products', 'Goals_ProductName', 'Goals.getItemsName', $ecommerceCustomParams);
$goalReportsByDimension->addReport(
'Goals_Products', 'Goals_ProductCategory', 'Goals.getItemsCategory', $ecommerceCustomParams);
} }
if ($conversions > 0) { if ($conversions > 0) {
......
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