13 class Collection extends \Magento\Sales\Model\ResourceModel\Report\Collection\AbstractCollection
66 $this->_ruleFactory = $ruleFactory;
67 $resource->init($this->_aggregationTable);
79 if (
'month' == $this->_period) {
80 $this->_periodFormat =
$connection->getDateFormatSql(
'period',
'%Y-%m');
81 }
elseif (
'year' == $this->_period) {
82 $this->_periodFormat =
$connection->getDateExtractSql(
87 $this->_periodFormat =
$connection->getDateFormatSql(
'period',
'%Y-%m-%d');
91 $this->_selectedColumns = [
95 'coupon_uses' =>
'SUM(coupon_uses)',
96 'subtotal_amount' =>
'SUM(subtotal_amount)',
97 'discount_amount' =>
'SUM(discount_amount)',
98 'total_amount' =>
'SUM(total_amount)',
99 'subtotal_amount_actual' =>
'SUM(subtotal_amount_actual)',
100 'discount_amount_actual' =>
'SUM(discount_amount_actual)',
101 'total_amount_actual' =>
'SUM(total_amount_actual)',
125 $this->
getSelect()->group($this->_periodFormat);
129 $this->_periodFormat,
135 return parent::_applyAggregatedTable();
146 $this->_rulesIdsFilter = $rulesList;
157 if (empty($this->_rulesIdsFilter) || !is_array($this->_rulesIdsFilter)) {
161 $rulesList = $this->_ruleFactory->create()->getUniqRulesNamesList();
163 $rulesFilterSqlParts = [];
164 foreach ($this->_rulesIdsFilter as
$ruleId) {
165 if (!isset($rulesList[
$ruleId])) {
168 $ruleName = $rulesList[
$ruleId];
169 $rulesFilterSqlParts[] = $this->
getConnection()->quoteInto(
'rule_name = ?', $ruleName);
172 if (!empty($rulesFilterSqlParts)) {
173 $this->
getSelect()->where(implode(
' OR ', $rulesFilterSqlParts));
186 return parent::_applyCustomFilter();
__construct(\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Sales\Model\ResourceModel\Report $resource, \Magento\SalesRule\Model\ResourceModel\Report\RuleFactory $ruleFactory, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null)
elseif(isset( $params[ 'redirect_parent']))
addRuleFilter(array $rulesList)