Skip to content

Commit b8e6b4d

Browse files
committed
ACP2E-56 : [On Prem] Magento invoice order date filter not working
1 parent 20ffc77 commit b8e6b4d

File tree

7 files changed

+129
-149
lines changed

7 files changed

+129
-149
lines changed

app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public function addFieldToFilter($field, $condition = null)
117117
}
118118

119119
/**
120+
* Get aggregation interface instance
121+
*
120122
* @return AggregationInterface
121123
*/
122124
public function getAggregations()
@@ -125,6 +127,8 @@ public function getAggregations()
125127
}
126128

127129
/**
130+
* Set aggregation interface instance
131+
*
128132
* @param AggregationInterface $aggregations
129133
* @return $this
130134
*/

app/code/Magento/Cms/Model/ResourceModel/Page/Grid/Collection.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class Collection extends PageCollection implements SearchResultInterface
4646
* @param mixed $eventObject
4747
* @param mixed $resourceModel
4848
* @param string $model
49-
* @param null $connection
50-
* @param AbstractDb|null $resource,
49+
* @param mixed|null $connection
50+
* @param AbstractDb|null $resource
5151
* @param TimezoneInterface|null $timeZone
5252
*
5353
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -117,6 +117,8 @@ public function addFieldToFilter($field, $condition = null)
117117
}
118118

119119
/**
120+
* Get aggregation interface instance
121+
*
120122
* @return AggregationInterface
121123
*/
122124
public function getAggregations()
@@ -125,6 +127,8 @@ public function getAggregations()
125127
}
126128

127129
/**
130+
* Set aggregation interface instance
131+
*
128132
* @param AggregationInterface $aggregations
129133
* @return $this
130134
*/
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Model\ResourceModel\Order;
8+
9+
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
10+
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
11+
use Magento\Framework\Event\ManagerInterface as EventManager;
12+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
13+
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
14+
use Psr\Log\LoggerInterface as Logger;
15+
16+
class CollectionFilter extends SearchResult
17+
{
18+
/**
19+
* @var TimezoneInterface
20+
*/
21+
private $timeZone;
22+
23+
/**
24+
* Initialize dependencies.
25+
*
26+
* @param EntityFactory $entityFactory
27+
* @param Logger $logger
28+
* @param FetchStrategy $fetchStrategy
29+
* @param EventManager $eventManager
30+
* @param string $mainTable
31+
* @param string $resourceModel
32+
* @param TimezoneInterface $timeZone
33+
*/
34+
public function __construct(
35+
EntityFactory $entityFactory,
36+
Logger $logger,
37+
FetchStrategy $fetchStrategy,
38+
EventManager $eventManager,
39+
TimezoneInterface $timeZone,
40+
$mainTable,
41+
$resourceModel
42+
) {
43+
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
44+
$this->timeZone = $timeZone;
45+
}
46+
47+
/**
48+
* @inheritdoc
49+
*/
50+
protected function _initSelect()
51+
{
52+
parent::_initSelect();
53+
54+
$tableDescription = $this->getConnection()->describeTable($this->getMainTable());
55+
foreach ($tableDescription as $columnInfo) {
56+
$this->addFilterToMap($columnInfo['COLUMN_NAME'], 'main_table.'.$columnInfo['COLUMN_NAME']);
57+
}
58+
59+
return $this;
60+
}
61+
62+
/**
63+
* @inheritDoc
64+
*/
65+
public function addFieldToFilter($field, $condition = null)
66+
{
67+
if ($field === 'created_at' || $field === 'order_created_at') {
68+
if (is_array($condition)) {
69+
foreach ($condition as $key => $value) {
70+
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
71+
}
72+
}
73+
}
74+
75+
return parent::addFieldToFilter($field, $condition);
76+
}
77+
}

app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Grid/Collection.php

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,33 @@
66

77
namespace Magento\Sales\Model\ResourceModel\Order\Creditmemo\Grid;
88

9-
use Magento\Framework\App\ObjectManager;
109
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
1110
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
1211
use Magento\Framework\Event\ManagerInterface as EventManager;
13-
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1412
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
1513
use Magento\Sales\Model\ResourceModel\Order\Creditmemo;
1614
use Psr\Log\LoggerInterface as Logger;
1715

1816
class Collection extends SearchResult
1917
{
20-
/**
21-
* @var TimezoneInterface
22-
*/
23-
private $timeZone;
24-
2518
/**
2619
* Initialize dependencies.
2720
*
28-
* @param EntityFactory $entityFactory
29-
* @param Logger $logger
30-
* @param FetchStrategy $fetchStrategy
31-
* @param EventManager $eventManager
32-
* @param string $mainTable
33-
* @param string $resourceModel
34-
* @param TimezoneInterface|null $timeZone
21+
* @param EntityFactory $entityFactory
22+
* @param Logger $logger
23+
* @param FetchStrategy $fetchStrategy
24+
* @param EventManager $eventManager
25+
* @param string $mainTable
26+
* @param string $resourceModel
3527
*/
3628
public function __construct(
3729
EntityFactory $entityFactory,
3830
Logger $logger,
3931
FetchStrategy $fetchStrategy,
4032
EventManager $eventManager,
41-
$mainTable='sales_creditmemo_grid',
42-
$resourceModel= Creditmemo::class,
43-
TimezoneInterface $timeZone = null
33+
$mainTable = 'sales_creditmemo_grid',
34+
$resourceModel = Creditmemo::class
4435
) {
4536
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
46-
$this->timeZone = $timeZone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
47-
}
48-
49-
/**
50-
* @inheritdoc
51-
*/
52-
protected function _initSelect()
53-
{
54-
parent::_initSelect();
55-
56-
$tableDescription = $this->getConnection()->describeTable($this->getMainTable());
57-
foreach ($tableDescription as $columnInfo) {
58-
$this->addFilterToMap($columnInfo['COLUMN_NAME'], 'main_table.'.$columnInfo['COLUMN_NAME']);
59-
}
60-
61-
return $this;
62-
}
63-
64-
/**
65-
* @inheritDoc
66-
*/
67-
public function addFieldToFilter($field, $condition = null)
68-
{
69-
if ($field === 'created_at' || $field === 'order_created_at') {
70-
if (is_array($condition)) {
71-
foreach ($condition as $key => $value) {
72-
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
73-
}
74-
}
75-
}
76-
77-
return parent::addFieldToFilter($field, $condition);
7837
}
7938
}

app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,33 @@
66

77
namespace Magento\Sales\Model\ResourceModel\Order\Invoice\Grid;
88

9-
use Magento\Framework\App\ObjectManager;
109
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
1110
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
1211
use Magento\Framework\Event\ManagerInterface as EventManager;
13-
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1412
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
1513
use Magento\Sales\Model\ResourceModel\Order\Invoice;
1614
use Psr\Log\LoggerInterface as Logger;
1715

1816
class Collection extends SearchResult
1917
{
20-
/**
21-
* @var TimezoneInterface
22-
*/
23-
private $timeZone;
24-
2518
/**
2619
* Initialize dependencies.
2720
*
28-
* @param EntityFactory $entityFactory
29-
* @param Logger $logger
30-
* @param FetchStrategy $fetchStrategy
31-
* @param EventManager $eventManager
32-
* @param string $mainTable
33-
* @param string $resourceModel
34-
* @param TimezoneInterface|null $timeZone
21+
* @param EntityFactory $entityFactory
22+
* @param Logger $logger
23+
* @param FetchStrategy $fetchStrategy
24+
* @param EventManager $eventManager
25+
* @param string $mainTable
26+
* @param string $resourceModel
3527
*/
3628
public function __construct(
3729
EntityFactory $entityFactory,
3830
Logger $logger,
3931
FetchStrategy $fetchStrategy,
4032
EventManager $eventManager,
41-
$mainTable='sales_invoice_grid',
42-
$resourceModel=Invoice::class,
43-
TimezoneInterface $timeZone = null
33+
$mainTable = 'sales_invoice_grid',
34+
$resourceModel = Invoice::class
4435
) {
4536
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
46-
$this->timeZone = $timeZone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
47-
}
48-
49-
/**
50-
* @inheritdoc
51-
*/
52-
protected function _initSelect()
53-
{
54-
parent::_initSelect();
55-
56-
$tableDescription = $this->getConnection()->describeTable($this->getMainTable());
57-
foreach ($tableDescription as $columnInfo) {
58-
$this->addFilterToMap($columnInfo['COLUMN_NAME'], 'main_table.'.$columnInfo['COLUMN_NAME']);
59-
}
60-
61-
return $this;
62-
}
63-
64-
/**
65-
* @inheritDoc
66-
*/
67-
public function addFieldToFilter($field, $condition = null)
68-
{
69-
if ($field === 'created_at' || $field === 'order_created_at') {
70-
if (is_array($condition)) {
71-
foreach ($condition as $key => $value) {
72-
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
73-
}
74-
}
75-
}
76-
77-
return parent::addFieldToFilter($field, $condition);
7837
}
7938
}

app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Grid/Collection.php

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,33 @@
66

77
namespace Magento\Sales\Model\ResourceModel\Order\Shipment\Grid;
88

9-
use Magento\Framework\App\ObjectManager;
109
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
1110
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
1211
use Magento\Framework\Event\ManagerInterface as EventManager;
13-
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1412
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
1513
use Magento\Sales\Model\ResourceModel\Order\Shipment;
1614
use Psr\Log\LoggerInterface as Logger;
1715

1816
class Collection extends SearchResult
1917
{
20-
/**
21-
* @var TimezoneInterface
22-
*/
23-
private $timeZone;
24-
2518
/**
2619
* Initialize dependencies.
2720
*
28-
* @param EntityFactory $entityFactory
29-
* @param Logger $logger
30-
* @param FetchStrategy $fetchStrategy
31-
* @param EventManager $eventManager
32-
* @param string $mainTable
33-
* @param string $resourceModel
34-
* @param TimezoneInterface|null $timeZone
21+
* @param EntityFactory $entityFactory
22+
* @param Logger $logger
23+
* @param FetchStrategy $fetchStrategy
24+
* @param EventManager $eventManager
25+
* @param string $mainTable
26+
* @param string $resourceModel
3527
*/
3628
public function __construct(
3729
EntityFactory $entityFactory,
3830
Logger $logger,
3931
FetchStrategy $fetchStrategy,
4032
EventManager $eventManager,
41-
$mainTable='sales_shipment_grid',
42-
$resourceModel= Shipment::class,
43-
TimezoneInterface $timeZone = null
33+
$mainTable = 'sales_shipment_grid',
34+
$resourceModel = Shipment::class
4435
) {
4536
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
46-
$this->timeZone = $timeZone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
47-
}
48-
49-
/**
50-
* @inheritdoc
51-
*/
52-
protected function _initSelect()
53-
{
54-
parent::_initSelect();
55-
56-
$tableDescription = $this->getConnection()->describeTable($this->getMainTable());
57-
foreach ($tableDescription as $columnInfo) {
58-
$this->addFilterToMap($columnInfo['COLUMN_NAME'], 'main_table.'.$columnInfo['COLUMN_NAME']);
59-
}
60-
61-
return $this;
62-
}
63-
64-
/**
65-
* @inheritDoc
66-
*/
67-
public function addFieldToFilter($field, $condition = null)
68-
{
69-
if ($field === 'created_at' || $field === 'order_created_at') {
70-
if (is_array($condition)) {
71-
foreach ($condition as $key => $value) {
72-
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
73-
}
74-
}
75-
}
76-
77-
return parent::addFieldToFilter($field, $condition);
7837
}
7938
}

app/code/Magento/Sales/etc/di.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,24 @@
839839
</argument>
840840
</arguments>
841841
</type>
842+
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Invoice\Grid\Collection" type="Magento\Sales\Model\ResourceModel\Order\CollectionFilter">
843+
<arguments>
844+
<argument name="mainTable" xsi:type="string">sales_invoice_grid</argument>
845+
<argument name="resourceModel" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Invoice</argument>
846+
</arguments>
847+
</virtualType>
848+
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Shipment\Grid\Collection" type="Magento\Sales\Model\ResourceModel\Order\CollectionFilter">
849+
<arguments>
850+
<argument name="mainTable" xsi:type="string">sales_shipment_grid</argument>
851+
<argument name="resourceModel" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Shipment</argument>
852+
</arguments>
853+
</virtualType>
854+
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Creditmemo\Grid\Collection" type="Magento\Sales\Model\ResourceModel\Order\CollectionFilter">
855+
<arguments>
856+
<argument name="mainTable" xsi:type="string">sales_creditmemo_grid</argument>
857+
<argument name="resourceModel" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Creditmemo</argument>
858+
</arguments>
859+
</virtualType>
842860
<type name="Magento\Sales\Model\Order\Config">
843861
<arguments>
844862
<argument name="state" xsi:type="object">Magento\Framework\App\State\Proxy</argument>

0 commit comments

Comments
 (0)