File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -89,12 +89,14 @@ public function getList(
89
89
$ this ->getSearchResultsApplier ($ searchResult , $ collection , $ this ->getSortOrderArray ($ searchCriteria ))->apply ();
90
90
91
91
//Additional applier to keep sorting from search
92
- $ items = [];
93
- foreach ($ searchResult ->getItems () as $ item ) {
94
- $ items [] = $ item ->getId ();
92
+ if (!empty ($ searchResult ->getItems ())) {
93
+ $ items = [];
94
+ foreach ($ searchResult ->getItems () as $ item ) {
95
+ $ items [] = $ item ->getId ();
96
+ }
97
+ $ orderList = join (', ' , $ items );
98
+ $ collection ->getSelect ()->order (new \Zend_Db_Expr ("FIELD(e.entity_id, $ orderList) " ));
95
99
}
96
- $ orderList = join (', ' , $ items );
97
- $ collection ->getSelect ()->order (new \Zend_Db_Expr ("FIELD(e.entity_id, $ orderList) " ));
98
100
99
101
$ this ->collectionPreProcessor ->process ($ collection , $ searchCriteria , $ attributes );
100
102
$ collection ->load ();
You can’t perform that action at this time.
0 commit comments