Skip to content

Commit 9c35563

Browse files
committed
ACP2E-4239: Date Filter not working according to store timezone on Credit Memos grid
1 parent 2f4c08c commit 9c35563

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

app/code/Magento/Catalog/Ui/Component/Listing/Columns.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function prepare()
7171
$config['sortOrder'] = ++$columnSortOrder;
7272
if ($attribute->getIsFilterableInGrid()) {
7373
$config['filter'] = $this->getFilterType($attribute->getFrontendInput());
74+
$config['userDefined'] = $attribute->getIsUserDefined();
7475
}
7576
$column = $this->columnFactory->create($attribute, $this->getContext(), $config);
7677
$column->prepare();

app/code/Magento/Ui/Component/Filters.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,16 @@ public function update(UiComponentInterface $component)
114114
}
115115

116116
if (isset($this->filterMap[$filterType]) && !isset($this->columnFilters[$component->getName()])) {
117+
$config = (array) $component->getConfig();
118+
$userDefined = (bool) ($config['userDefined'] ?? 0);
119+
117120
$filterComponent = $this->uiComponentFactory->create(
118121
$component->getName(),
119122
$this->filterMap[$filterType],
120-
['context' => $this->getContext()]
123+
[
124+
'context' => $this->getContext(),
125+
'userDefined' => $userDefined,
126+
]
121127
);
122128
$filterComponent->setData('config', $component->getConfiguration());
123129
$filterComponent->prepare();

app/code/Magento/Ui/Component/Filters/Type/Date.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
namespace Magento\Ui\Component\Filters\Type;
88

9+
use Magento\Framework\Api\FilterBuilder;
10+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
11+
use Magento\Framework\View\Element\UiComponentFactory;
12+
use Magento\Ui\Component\Filters\FilterModifier;
913
use Magento\Ui\Component\Form\Element\DataType\Date as DataTypeDate;
1014

1115
/**
@@ -31,6 +35,33 @@ class Date extends AbstractFilter
3135
*/
3236
protected static $dateFormat = 'Y-m-d H:i:s';
3337

38+
/**
39+
* @var bool
40+
*/
41+
private bool $userDefined;
42+
43+
/**
44+
* @param ContextInterface $context
45+
* @param UiComponentFactory $uiComponentFactory
46+
* @param FilterBuilder $filterBuilder
47+
* @param FilterModifier $filterModifier
48+
* @param array $components
49+
* @param array $data
50+
* @param bool $userDefined
51+
*/
52+
public function __construct(
53+
ContextInterface $context,
54+
UiComponentFactory $uiComponentFactory,
55+
FilterBuilder $filterBuilder,
56+
FilterModifier $filterModifier,
57+
array $components = [],
58+
array $data = [],
59+
bool $userDefined = false
60+
) {
61+
$this->userDefined = $userDefined;
62+
parent::__construct($context, $uiComponentFactory, $filterBuilder, $filterModifier, $components, $data);
63+
}
64+
3465
/**
3566
* Prepare component configuration
3667
*
@@ -138,7 +169,8 @@ private function convertDatetime(string $value, int $hour = 0, int $minute = 0,
138169
$hour,
139170
$minute,
140171
$second,
141-
!$this->getData('config/skipTimeZoneConversion')
172+
!$this->getData('config/skipTimeZoneConversion'),
173+
!$this->userDefined
142174
);
143175

144176
return $value;

0 commit comments

Comments
 (0)