Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Ecommerce/Reports')
-rw-r--r--plugins/Ecommerce/Reports/Base.php5
-rw-r--r--plugins/Ecommerce/Reports/BaseItem.php45
-rw-r--r--plugins/Ecommerce/Reports/GetItemsCategory.php3
-rw-r--r--plugins/Ecommerce/Reports/GetItemsName.php3
-rw-r--r--plugins/Ecommerce/Reports/GetItemsSku.php3
5 files changed, 46 insertions, 13 deletions
diff --git a/plugins/Ecommerce/Reports/Base.php b/plugins/Ecommerce/Reports/Base.php
index 08a766792a..28a3a4a36f 100644
--- a/plugins/Ecommerce/Reports/Base.php
+++ b/plugins/Ecommerce/Reports/Base.php
@@ -8,20 +8,17 @@
*/
namespace Piwik\Plugins\Ecommerce\Reports;
-use Piwik\API\Proxy;
use Piwik\Common;
use Piwik\Piwik;
use Piwik\Plugin\Report;
use Piwik\Site;
-use Piwik\ViewDataTable\Factory as ViewDataTableFactory;
-use Piwik\WidgetsList;
abstract class Base extends Report
{
protected function init()
{
$this->module = 'Goals';
- $this->category = 'Goals_Ecommerce';
+ $this->categoryId = 'Goals_Ecommerce';
}
public function isEnabled()
diff --git a/plugins/Ecommerce/Reports/BaseItem.php b/plugins/Ecommerce/Reports/BaseItem.php
index 5caf770a6b..5896710dc2 100644
--- a/plugins/Ecommerce/Reports/BaseItem.php
+++ b/plugins/Ecommerce/Reports/BaseItem.php
@@ -9,15 +9,18 @@
namespace Piwik\Plugins\Ecommerce\Reports;
use Piwik\Common;
+use Piwik\DataTable;
use Piwik\Metrics\Formatter;
use Piwik\Piwik;
-use Piwik\Plugin\Report;
use Piwik\Plugin\ViewDataTable;
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution;
-use Piwik\Plugins\Goals\Goals;
use Piwik\Plugins\Goals\Columns\Metrics\AveragePrice;
use Piwik\Plugins\Goals\Columns\Metrics\AverageQuantity;
use Piwik\Plugins\Goals\Columns\Metrics\ProductConversionRate;
+use Piwik\Plugins\Goals\Conversions;
+use Piwik\Plugins\Goals\Model;
+use Piwik\Report\ReportWidgetFactory;
+use Piwik\Widget\WidgetsList;
abstract class BaseItem extends Base
{
@@ -46,7 +49,8 @@ abstract class BaseItem extends Base
public function getMetricsDocumentation()
{
- if ($this->isAbandonedCart()) {
+ // we do not check whether it is abondon carts if not set re performance improvements
+ if ($this->isAbandonedCart($fetchIfNotSet = false)) {
return array(
'revenue' => Piwik::translate('Goals_ColumnRevenueDocumentation',
Piwik::translate('Goals_DocumentationRevenueGeneratedByProductSales')),
@@ -62,6 +66,11 @@ abstract class BaseItem extends Base
return array();
}
+ public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
+ {
+ $widgetsList->addToContainerWidget('Products', $factory->createWidget());
+ }
+
public function configureView(ViewDataTable $view)
{
$idSite = Common::getRequestVar('idSite');
@@ -100,7 +109,7 @@ abstract class BaseItem extends Base
$view->config->custom_parameters['viewDataTable'] = 'table';
$abandonedCart = true;
} else {
- $abandonedCart = $this->isAbandonedCart();
+ $abandonedCart = $this->isAbandonedCart($fetchIfNotSet = true);
}
if ($abandonedCart) {
@@ -127,8 +136,32 @@ abstract class BaseItem extends Base
$view->config->columns_to_display = $columnsOrdered;
}
- private function isAbandonedCart()
+ private function isAbandonedCart($fetchIfNotSet)
{
- return Common::getRequestVar('abandonedCarts', '0', 'string') == 1;
+ $abandonedCarts = Common::getRequestVar('abandonedCarts', '', 'string');
+
+ if ($abandonedCarts === '') {
+ if ($fetchIfNotSet) {
+
+ $idSite = Common::getRequestVar('idSite', 0, 'int');
+ $period = Common::getRequestVar('period', '', 'string');
+ $date = Common::getRequestVar('date', '', 'string');
+
+ $conversion = new Conversions();
+ $conversions = $conversion->getConversionForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER, $idSite, $period, $date);
+ $cartNbConversions = $conversion->getConversionForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART, $idSite, $period, $date);
+ $preloadAbandonedCart = $cartNbConversions !== false && $conversions == 0;
+
+ if ($preloadAbandonedCart) {
+ $abandonedCarts = '1';
+ } else {
+ $abandonedCarts = '0';
+ }
+ } else {
+ $abandonedCarts = '0';
+ }
+ }
+
+ return $abandonedCarts == '1';
}
}
diff --git a/plugins/Ecommerce/Reports/GetItemsCategory.php b/plugins/Ecommerce/Reports/GetItemsCategory.php
index bf652ca10d..efd4a9489a 100644
--- a/plugins/Ecommerce/Reports/GetItemsCategory.php
+++ b/plugins/Ecommerce/Reports/GetItemsCategory.php
@@ -20,6 +20,7 @@ class GetItemsCategory extends BaseItem
$this->name = Piwik::translate('Goals_ProductCategory');
$this->dimension = new ProductCategory();
$this->order = 32;
- $this->widgetTitle = 'Goals_ProductCategory';
+
+ $this->subcategoryId = 'Goals_Products';
}
}
diff --git a/plugins/Ecommerce/Reports/GetItemsName.php b/plugins/Ecommerce/Reports/GetItemsName.php
index a320b760e4..db8c7f5d3d 100644
--- a/plugins/Ecommerce/Reports/GetItemsName.php
+++ b/plugins/Ecommerce/Reports/GetItemsName.php
@@ -20,6 +20,7 @@ class GetItemsName extends BaseItem
$this->name = Piwik::translate('Goals_ProductName');
$this->dimension = new ProductName();
$this->order = 31;
- $this->widgetTitle = 'Goals_ProductName';
+
+ $this->subcategoryId = 'Goals_Products';
}
}
diff --git a/plugins/Ecommerce/Reports/GetItemsSku.php b/plugins/Ecommerce/Reports/GetItemsSku.php
index a2b20eb3f9..9056b2ff6c 100644
--- a/plugins/Ecommerce/Reports/GetItemsSku.php
+++ b/plugins/Ecommerce/Reports/GetItemsSku.php
@@ -21,7 +21,8 @@ class GetItemsSku extends BaseItem
$this->name = Piwik::translate('Goals_ProductSKU');
$this->dimension = new ProductSku();
$this->order = 30;
- $this->widgetTitle = 'Goals_ProductSKU';
+
+ $this->subcategoryId = 'Goals_Products';
}
}