diff --git a/vendor/magento/module-customer/Model/ResourceModel/Grid/Collection.php b/vendor/magento/module-customer/Model/ResourceModel/Grid/Collection.php index 0fab27161ce..e14594daf80 100644 --- a/vendor/magento/module-customer/Model/ResourceModel/Grid/Collection.php +++ b/vendor/magento/module-customer/Model/ResourceModel/Grid/Collection.php @@ -7,10 +7,12 @@ namespace Magento\Customer\Model\ResourceModel\Grid; use Magento\Customer\Model\ResourceModel\Customer; use Magento\Customer\Ui\Component\DataProvider\Document; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy; use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory; use Magento\Framework\Event\ManagerInterface as EventManager; use Magento\Framework\Locale\ResolverInterface; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult; use Psr\Log\LoggerInterface as Logger; @@ -25,6 +27,11 @@ class Collection extends SearchResult private $localeResolver; /** + * @var TimezoneInterface + */ + private $timeZone; + + /** * @inheritdoc */ protected $document = Document::class; @@ -42,6 +49,7 @@ class Collection extends SearchResult * @param ResolverInterface $localeResolver * @param string $mainTable * @param string $resourceModel + * @param TimezoneInterface|null $timeZone */ public function __construct( EntityFactory $entityFactory, @@ -50,10 +58,13 @@ class Collection extends SearchResult EventManager $eventManager, ResolverInterface $localeResolver, $mainTable = 'customer_grid_flat', - $resourceModel = Customer::class + $resourceModel = Customer::class, + TimezoneInterface $timeZone = null ) { $this->localeResolver = $localeResolver; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); + $this->timeZone = $timeZone ?: ObjectManager::getInstance() + ->get(TimezoneInterface::class); } /** @@ -81,6 +92,14 @@ class Collection extends SearchResult return $this; } + if ($field === 'created_at') { + if (is_array($condition)) { + foreach ($condition as $key => $value) { + $condition[$key] = $this->timeZone->convertConfigTimeToUtc($value); + } + } + } + if (is_string($field) && count(explode('.', $field)) === 1) { $field = 'main_table.' . $field; }