22 parent::__construct(
$resource, $modulePrefix);
51 $periodCol =
$connection->getDateFormatSql(
't.period',
'%Y-01-01');
54 $periodCol =
$connection->getDateFormatSql(
't.period',
'%Y-%m-01');
57 $periodCol =
't.period';
62 'period' =>
't.period',
63 'store_id' =>
't.store_id',
64 'product_id' =>
't.product_id',
65 'product_name' =>
't.product_name',
66 'product_price' =>
't.product_price',
74 $cols[
'total_qty'] = new \Zend_Db_Expr(
'SUM(t.' . $column .
')');
75 $periodSubSelect->from(
79 [
't.store_id', $periodCol,
't.product_id']
81 [
't.store_id', $periodCol,
'total_qty DESC']
85 $cols[$column] =
't.total_qty';
86 $cols[
'rating_pos'] = new \Zend_Db_Expr(
87 "(@pos := IF(t.`store_id` <> @prevStoreId OR {$periodCol} <> @prevPeriod, 1, @pos+1))" 89 $cols[
'prevStoreId'] = new \Zend_Db_Expr(
'(@prevStoreId := t.`store_id`)');
90 $cols[
'prevPeriod'] = new \Zend_Db_Expr(
"(@prevPeriod := {$periodCol})");
91 $ratingSubSelect->from($periodSubSelect, $cols);
94 $cols[
'period'] = $periodCol;
95 $cols[$column] =
't.' . $column;
96 $cols[
'rating_pos'] =
't.rating_pos';
97 $ratingSelect->from($ratingSubSelect, $cols);
99 $sql = $ratingSelect->insertFromSelect($aggregationTable, array_keys($cols));
100 $connection->query(
"SET @pos = 0, @prevStoreId = -1, @prevPeriod = '0000-00-00'");
__construct(\Magento\Framework\App\ResourceConnection $resource, $modulePrefix='reports')
updateReportRatingPos($connection, $type, $column, $mainTable, $aggregationTable)
mergeVisitorProductIndex($mainTable, $data, $matchFields)