@@ -99,6 +99,7 @@ public function getCollection(AbstractDb $collection)
99
99
throw new LocalizedException (__ ('Please select item(s). ' ));
100
100
}
101
101
}
102
+ /** @var \Magento\Customer\Model\ResourceModel\Customer\Collection $collection */
102
103
$ idsArray = $ this ->getFilterIds ();
103
104
if (!empty ($ idsArray )) {
104
105
$ collection ->addFieldToFilter (
@@ -220,14 +221,21 @@ private function getFilterIds()
220
221
$ idsArray = [];
221
222
$ this ->applySelectionOnTargetProvider ();
222
223
if ($ this ->getDataProvider () instanceof \Magento \Ui \DataProvider \AbstractDataProvider) {
223
- // Use collection's getItems for optimization purposes
224
- return $ this ->getDataProvider ()->getAllIds ();
224
+ // Use collection's getItems for optimization purposes.
225
+ $ idsArray = $ this ->getDataProvider ()->getAllIds ();
225
226
} else {
226
227
$ searchResult = $ this ->getDataProvider ()->getSearchResult ();
227
- // Use compatible search api getItems when searchResult is not a collection.
228
- foreach ($ searchResult ->getItems () as $ item ) {
229
- /** @var $item \Magento\Framework\Api\Search\DocumentInterface */
230
- $ idsArray [] = $ item ->getId ();
228
+ if ($ searchResult instanceof \Magento \Eav \Model \Entity \Collection \AbstractCollection
229
+ || $ searchResult instanceof \Magento \Framework \Model \ResourceModel \Db \Collection \AbstractCollection
230
+ ) {
231
+ // Use collection's getItems for optimization purposes.
232
+ $ idsArray = $ searchResult ->getAllIds ();
233
+ } else {
234
+ // Use compatible search api getItems when searchResult is not a collection.
235
+ foreach ($ searchResult ->getItems () as $ item ) {
236
+ /** @var $item \Magento\Framework\Api\Search\DocumentInterface */
237
+ $ idsArray [] = $ item ->getId ();
238
+ }
231
239
}
232
240
}
233
241
return $ idsArray ;
0 commit comments