@@ -100,10 +100,7 @@ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria)
100
100
/** @var \Magento\Sales\Api\Data\OrderSearchResultInterface $searchResult */
101
101
$ searchResult = $ this ->searchResultFactory ->create ();
102
102
foreach ($ searchCriteria ->getFilterGroups () as $ filterGroup ) {
103
- foreach ($ filterGroup ->getFilters () as $ filter ) {
104
- $ condition = $ filter ->getConditionType () ? $ filter ->getConditionType () : 'eq ' ;
105
- $ searchResult ->addFieldToFilter ($ filter ->getField (), [$ condition => $ filter ->getValue ()]);
106
- }
103
+ $ this ->addFilterGroupToCollection ($ filterGroup , $ searchResult );
107
104
}
108
105
109
106
$ sortOrders = $ searchCriteria ->getSortOrders ();
@@ -216,4 +213,28 @@ private function getShippingAssignmentBuilderDependency()
216
213
}
217
214
return $ this ->shippingAssignmentBuilder ;
218
215
}
216
+
217
+ /**
218
+ * Helper function that adds a FilterGroup to the collection.
219
+ *
220
+ * @param \Magento\Framework\Api\Search\FilterGroup $filterGroup
221
+ * @param \Magento\Sales\Api\Data\OrderSearchResultInterface $searchResult
222
+ * @return void
223
+ * @throws \Magento\Framework\Exception\InputException
224
+ */
225
+ protected function addFilterGroupToCollection (
226
+ \Magento \Framework \Api \Search \FilterGroup $ filterGroup ,
227
+ \Magento \Sales \Api \Data \OrderSearchResultInterface $ searchResult
228
+ ) {
229
+ $ fields = [];
230
+ $ conditions = [];
231
+ foreach ($ filterGroup ->getFilters () as $ filter ) {
232
+ $ condition = $ filter ->getConditionType () ? $ filter ->getConditionType () : 'eq ' ;
233
+ $ conditions [] = [$ condition => $ filter ->getValue ()];
234
+ $ fields [] = $ filter ->getField ();
235
+ }
236
+ if ($ fields ) {
237
+ $ searchResult ->addFieldToFilter ($ fields , $ conditions );
238
+ }
239
+ }
219
240
}
0 commit comments