36 \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE => \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE,
55 \
Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
56 \
Magento\Reports\Model\FlagFactory $reportsFlagFactory,
74 $this->_salesResourceHelper = $salesResourceHelper;
85 $this->
_init(
'sales_bestsellers_aggregated_' . self::AGGREGATION_DAILY,
'id');
103 if ($from !==
null || $to !==
null) {
119 [
'source_table' => $this->
getTable(
'sales_order')],
120 'source_table.created_at',
127 $select->group([$periodExpr,
'source_table.store_id',
'order_item.product_id']);
130 'period' => $periodExpr,
131 'store_id' =>
'source_table.store_id',
132 'product_id' =>
'order_item.product_id',
133 'product_name' => new \Zend_Db_Expr(
'MIN(order_item.name)'),
134 'product_price' => new \Zend_Db_Expr(
135 'MIN(IF(order_item_parent.base_price, order_item_parent.base_price, order_item.base_price))' .
136 '* MIN(source_table.base_to_global_rate)' 138 'qty_ordered' => new \Zend_Db_Expr(
'SUM(order_item.qty_ordered)'),
142 [
'source_table' => $this->
getTable(
'sales_order')],
145 [
'order_item' => $this->
getTable(
'sales_order_item')],
146 'order_item.order_id = source_table.entity_id',
149 [
'order_item_parent' => $this->
getTable(
'sales_order_item')],
150 'order_item.parent_item_id = order_item_parent.item_id',
153 'source_table.state != ?',
156 'order_item.product_type NOT IN(?)',
157 $this->ignoredProductTypes
160 if ($subSelect !==
null) {
170 'period' =>
'period',
171 'store_id' => new \Zend_Db_Expr(\
Magento\Store\Model\Store::DEFAULT_STORE_ID),
172 'product_id' =>
'product_id',
173 'product_name' => new \Zend_Db_Expr(
'MIN(product_name)'),
174 'product_price' => new \Zend_Db_Expr(
'MIN(product_price)'),
175 'qty_ordered' => new \Zend_Db_Expr(
'SUM(qty_ordered)'),
184 \
Magento\Store\Model\Store::DEFAULT_STORE_ID
187 if ($subSelect !==
null) {
191 $select->group([
'period',
'product_id']);
200 }
catch (\Exception $e) {
215 $aggregationTable = $this->
getTable(
'sales_bestsellers_aggregated_' . $aggregation);
217 $aggregationAliases = [
222 $this->_salesResourceHelper->getBestsellersReportUpdateRatingPos(
__construct(\Magento\Framework\Model\ResourceModel\Db\Context $context, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Reports\Model\FlagFactory $reportsFlagFactory, \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator, \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, \Magento\Catalog\Model\ResourceModel\Product $productResource, \Magento\Sales\Model\ResourceModel\Helper $salesResourceHelper, $connectionName=null, array $ignoredProductTypes=[])
_makeConditionFromDateRangeSelect($select, $periodColumn, $connection=null)
getStoreTZOffsetQuery( $table, $column, $from=null, $to=null, $store=null, $connection=null)
_clearTableByDateRange( $table, $from=null, $to=null, $subSelect=null, $doNotUseTruncate=false, $connection=null)
_init($mainTable, $idFieldName)
_updateRatingPos($aggregation)
_setFlagData($code, $value=null)
const AGGREGATION_MONTHLY
_getTableDateRangeSelect( $table, $column, $whereColumn, $from=null, $to=null, $additionalWhere=[], $alias='date_range_table')
aggregate($from=null, $to=null)