Skip to content

Commit aa18fe4

Browse files
committed
ACP2E-4239: Date Filter not working according to store timezone on Credit Memos grid
1 parent 57fe989 commit aa18fe4

File tree

3 files changed

+2
-159
lines changed

3 files changed

+2
-159
lines changed

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
use Magento\Framework\Api\Search\SearchResultInterface;
99
use Magento\Framework\Api\Search\AggregationInterface;
1010
use Magento\Cms\Model\ResourceModel\Block\Collection as BlockCollection;
11-
use Magento\Framework\App\ObjectManager;
1211
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
1312
use Magento\Framework\Data\Collection\EntityFactoryInterface;
1413
use Magento\Framework\DB\Adapter\AdapterInterface;
1514
use Magento\Framework\EntityManager\MetadataPool;
1615
use Magento\Framework\Event\ManagerInterface;
1716
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
18-
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1917
use Magento\Store\Model\StoreManagerInterface;
2018
use Psr\Log\LoggerInterface;
2119

@@ -24,11 +22,6 @@
2422
*/
2523
class Collection extends BlockCollection implements SearchResultInterface
2624
{
27-
/**
28-
* @var TimezoneInterface
29-
*/
30-
private $timeZone;
31-
3225
/**
3326
* @var AggregationInterface
3427
*/
@@ -54,7 +47,6 @@ class Collection extends BlockCollection implements SearchResultInterface
5447
* @param string $model
5548
* @param AdapterInterface|string|null $connection
5649
* @param AbstractDb $resource
57-
* @param TimezoneInterface|null $timeZone
5850
*
5951
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6052
*/
@@ -71,8 +63,7 @@ public function __construct(
7163
$resourceModel,
7264
$model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
7365
$connection = null,
74-
?AbstractDb $resource = null,
75-
?TimezoneInterface $timeZone = null
66+
?AbstractDb $resource = null
7667
) {
7768
$this->resourceModel = $resourceModel;
7869
$this->model = $model;
@@ -90,7 +81,6 @@ public function __construct(
9081
$this->_eventObject = $eventObject;
9182
$this->_init($this->model, $this->resourceModel);
9283
$this->setMainTable($mainTable);
93-
$this->timeZone = $timeZone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
9484
}
9585

9686
/**
@@ -102,22 +92,6 @@ public function _resetState(): void
10292
$this->_init($this->model, $this->resourceModel);
10393
}
10494

105-
/**
106-
* @inheritDoc
107-
*/
108-
public function addFieldToFilter($field, $condition = null)
109-
{
110-
if ($field === 'creation_time' || $field === 'update_time') {
111-
if (is_array($condition)) {
112-
foreach ($condition as $key => $value) {
113-
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
114-
}
115-
}
116-
}
117-
118-
return parent::addFieldToFilter($field, $condition);
119-
}
120-
12195
/**
12296
* Get aggregation interface instance
12397
*

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
use Magento\Framework\Api\Search\SearchResultInterface;
99
use Magento\Framework\Api\Search\AggregationInterface;
1010
use Magento\Cms\Model\ResourceModel\Page\Collection as PageCollection;
11-
use Magento\Framework\App\ObjectManager;
1211
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
1312
use Magento\Framework\Data\Collection\EntityFactoryInterface;
1413
use Magento\Framework\EntityManager\MetadataPool;
1514
use Magento\Framework\Event\ManagerInterface;
1615
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
17-
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1816
use Magento\Store\Model\StoreManagerInterface;
1917
use Psr\Log\LoggerInterface;
2018

@@ -24,11 +22,6 @@
2422
*/
2523
class Collection extends PageCollection implements SearchResultInterface
2624
{
27-
/**
28-
* @var TimezoneInterface
29-
*/
30-
private $timeZone;
31-
3225
/**
3326
* @var AggregationInterface
3427
*/
@@ -54,7 +47,6 @@ class Collection extends PageCollection implements SearchResultInterface
5447
* @param string $model
5548
* @param mixed|null $connection
5649
* @param AbstractDb|null $resource
57-
* @param TimezoneInterface|null $timeZone
5850
*
5951
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6052
*/
@@ -71,8 +63,7 @@ public function __construct(
7163
$resourceModel,
7264
$model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
7365
$connection = null,
74-
?AbstractDb $resource = null,
75-
?TimezoneInterface $timeZone = null
66+
?AbstractDb $resource = null
7667
) {
7768
$this->resourceModel = $resourceModel;
7869
$this->model = $model;
@@ -90,7 +81,6 @@ public function __construct(
9081
$this->_eventObject = $eventObject;
9182
$this->_init($this->model, $this->resourceModel);
9283
$this->setMainTable($mainTable);
93-
$this->timeZone = $timeZone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
9484
}
9585

9686
/**
@@ -102,22 +92,6 @@ public function _resetState(): void
10292
$this->_init($this->model, $this->resourceModel);
10393
}
10494

105-
/**
106-
* @inheritDoc
107-
*/
108-
public function addFieldToFilter($field, $condition = null)
109-
{
110-
if ($field === 'creation_time' || $field === 'update_time') {
111-
if (is_array($condition)) {
112-
foreach ($condition as $key => $value) {
113-
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
114-
}
115-
}
116-
}
117-
118-
return parent::addFieldToFilter($field, $condition);
119-
}
120-
12195
/**
12296
* Get aggregation interface instance
12397
*

dev/tests/integration/testsuite/Magento/Sales/Plugin/Model/ResourceModel/Order/OrderGridCollectionFilterTest.php

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)