Skip to content

Commit 315445e

Browse files
committed
ACP2E-56 : [On Prem] Magento invoice order date filter not working
1 parent 31d8a21 commit 315445e

File tree

3 files changed

+7
-32
lines changed

3 files changed

+7
-32
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Collection extends SearchResult
2525
* @param string $mainTable
2626
* @param string $resourceModel
2727
* @throws \Magento\Framework\Exception\LocalizedException
28+
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found
2829
*/
2930
public function __construct(
3031
EntityFactory $entityFactory,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Collection extends SearchResult
2525
* @param string $mainTable
2626
* @param string $resourceModel
2727
* @throws \Magento\Framework\Exception\LocalizedException
28+
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found
2829
*/
2930
public function __construct(
3031
EntityFactory $entityFactory,

app/code/Magento/Sales/Plugin/Model/ResourceModel/Order/OrderGridCollectionFilter.php

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class OrderGridCollectionFilter
1818
private TimezoneInterface $timeZone;
1919

2020
/**
21+
* Timezone converter interface
22+
*
2123
* @param TimezoneInterface $timeZone
2224
*/
2325
public function __construct(
@@ -26,19 +28,9 @@ public function __construct(
2628
$this->timeZone = $timeZone;
2729
}
2830

29-
private function _initSelect(SearchResult $subject)
30-
{
31-
$tableDescription = $subject->getConnection()->describeTable($subject->getMainTable());
32-
if ($tableDescription) {
33-
foreach ($tableDescription as $columnInfo) {
34-
$subject->addFilterToMap($columnInfo['COLUMN_NAME'], 'main_table.' . $columnInfo['COLUMN_NAME']);
35-
}
36-
}
37-
38-
return $subject;
39-
}
40-
4131
/**
32+
* Conditional column filters with timezone convertor interface
33+
*
4234
* @param SearchResult $subject
4335
* @param \Closure $proceed
4436
* @param string $field
@@ -52,12 +44,6 @@ public function aroundAddFieldToFilter(
5244
$field,
5345
$condition = null
5446
) {
55-
$this->_initSelect($subject);
56-
$fieldMap = $this->getFilterFieldsMap();
57-
$fieldName = $fieldMap['fields'][$field] ?? null;
58-
if (!$fieldName) {
59-
return $proceed($field, $condition);
60-
}
6147

6248
if ($field === 'created_at' || $field === 'order_created_at') {
6349
if (is_array($condition)) {
@@ -67,23 +53,10 @@ public function aroundAddFieldToFilter(
6753
}
6854
}
6955

70-
$fieldName = $subject->getConnection()->quoteIdentifier($fieldName);
56+
$fieldName = $subject->getConnection()->quoteIdentifier($field);
7157
$condition = $subject->getConnection()->prepareSqlCondition($fieldName, $condition);
7258
$subject->getSelect()->where($condition, null, Select::TYPE_CONDITION);
7359

7460
return $subject;
7561
}
76-
77-
/**
78-
* @return \string[][]
79-
*/
80-
private function getFilterFieldsMap(): array
81-
{
82-
return [
83-
'fields' => [
84-
'created_at' => 'main_table.created_at',
85-
'order_created_at' => 'main_table.order_created_at',
86-
],
87-
];
88-
}
8962
}

0 commit comments

Comments
 (0)