@@ -18,6 +18,8 @@ class OrderGridCollectionFilter
18
18
private TimezoneInterface $ timeZone ;
19
19
20
20
/**
21
+ * Timezone converter interface
22
+ *
21
23
* @param TimezoneInterface $timeZone
22
24
*/
23
25
public function __construct (
@@ -26,19 +28,9 @@ public function __construct(
26
28
$ this ->timeZone = $ timeZone ;
27
29
}
28
30
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
-
41
31
/**
32
+ * Conditional column filters with timezone convertor interface
33
+ *
42
34
* @param SearchResult $subject
43
35
* @param \Closure $proceed
44
36
* @param string $field
@@ -52,12 +44,6 @@ public function aroundAddFieldToFilter(
52
44
$ field ,
53
45
$ condition = null
54
46
) {
55
- $ this ->_initSelect ($ subject );
56
- $ fieldMap = $ this ->getFilterFieldsMap ();
57
- $ fieldName = $ fieldMap ['fields ' ][$ field ] ?? null ;
58
- if (!$ fieldName ) {
59
- return $ proceed ($ field , $ condition );
60
- }
61
47
62
48
if ($ field === 'created_at ' || $ field === 'order_created_at ' ) {
63
49
if (is_array ($ condition )) {
@@ -67,23 +53,10 @@ public function aroundAddFieldToFilter(
67
53
}
68
54
}
69
55
70
- $ fieldName = $ subject ->getConnection ()->quoteIdentifier ($ fieldName );
56
+ $ fieldName = $ subject ->getConnection ()->quoteIdentifier ($ field );
71
57
$ condition = $ subject ->getConnection ()->prepareSqlCondition ($ fieldName , $ condition );
72
58
$ subject ->getSelect ()->where ($ condition , null , Select::TYPE_CONDITION );
73
59
74
60
return $ subject ;
75
61
}
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
- }
89
62
}
0 commit comments