Skip to content

Commit 77e1e2b

Browse files
MC-40384: [Magento Cloud] Order Grid created time showing wrong
1 parent 1e846a4 commit 77e1e2b

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,25 @@
55
*/
66
namespace Magento\Sales\Model\ResourceModel\Order\Grid;
77

8+
use Magento\Framework\App\ObjectManager;
89
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
910
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
1011
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 Magento\Sales\Model\ResourceModel\Order;
1115
use Psr\Log\LoggerInterface as Logger;
1216

1317
/**
1418
* Order grid collection
1519
*/
16-
class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
20+
class Collection extends SearchResult
1721
{
22+
/**
23+
* @var TimezoneInterface
24+
*/
25+
private $timeZone;
26+
1827
/**
1928
* Initialize dependencies.
2029
*
@@ -24,16 +33,20 @@ class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvide
2433
* @param EventManager $eventManager
2534
* @param string $mainTable
2635
* @param string $resourceModel
36+
* @param TimezoneInterface|null $timeZone
2737
*/
2838
public function __construct(
2939
EntityFactory $entityFactory,
3040
Logger $logger,
3141
FetchStrategy $fetchStrategy,
3242
EventManager $eventManager,
3343
$mainTable = 'sales_order_grid',
34-
$resourceModel = \Magento\Sales\Model\ResourceModel\Order::class
44+
$resourceModel = Order::class,
45+
TimezoneInterface $timeZone = null
3546
) {
3647
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
48+
$this->timeZone = $timeZone ?: ObjectManager::getInstance()
49+
->get(TimezoneInterface::class);
3750
}
3851

3952
/**
@@ -50,4 +63,20 @@ protected function _initSelect()
5063

5164
return $this;
5265
}
66+
67+
/**
68+
* @inheritDoc
69+
*/
70+
public function addFieldToFilter($field, $condition = null)
71+
{
72+
if ($field === 'created_at') {
73+
if (is_array($condition)) {
74+
foreach ($condition as $key => $value) {
75+
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
76+
}
77+
}
78+
}
79+
80+
return parent::addFieldToFilter($field, $condition);
81+
}
5382
}

0 commit comments

Comments
 (0)