Skip to content

Commit ad02994

Browse files
committed
#31537: Magento2.4 GraphQL CustomerOrders Query Logic
1 parent e235082 commit ad02994

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/FilterProcessor.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ private function addFilterGroupToCollection(
8585
}
8686
}
8787

88+
$this->checkFromTo($fields, $conditions);
89+
8890
if ($fields) {
8991
$collection->addFieldToFilter($fields, $conditions);
9092
}
@@ -125,4 +127,26 @@ private function getFieldMapping($field)
125127
{
126128
return $this->fieldMapping[$field] ?? $field;
127129
}
130+
131+
/**
132+
* Check filtergoup for type from & to
133+
*
134+
* @param string[] $fields
135+
* @param array<string[]> $conditions
136+
* @return void
137+
*/
138+
private function checkFromTo(&$fields, &$conditions)
139+
{
140+
$_fields = array_unique($fields);
141+
$_conditions = [];
142+
foreach ($conditions as $condition) {
143+
$_conditions[array_key_first($condition)] = array_first($condition);
144+
}
145+
if ((count($_fields) == 1) && (count($_conditions) == 2)
146+
&& isset($_conditions['from']) && isset($_conditions['to'])
147+
) {
148+
$fields = $_fields;
149+
$conditions = [$_conditions];
150+
}
151+
}
128152
}

0 commit comments

Comments
 (0)