File tree Expand file tree Collapse file tree 4 files changed +24
-34
lines changed
lib/internal/Magento/Framework/View/Element Expand file tree Collapse file tree 4 files changed +24
-34
lines changed Original file line number Diff line number Diff line change @@ -301,29 +301,4 @@ protected function initObservers(array & $data = [])
301
301
}
302
302
}
303
303
}
304
-
305
-
306
- /**
307
- * Retrieve all ids from Search Result
308
- *
309
- * @return int[]
310
- */
311
- public function getAllIds ()
312
- {
313
- $ searchResult = $ this ->getContext ()->getDataProvider ()->getSearchResult ();
314
- $ idsArray = [];
315
-
316
- if ($ searchResult instanceof \Magento \Eav \Model \Entity \Collection \AbstractCollection
317
- || $ searchResult instanceof \Magento \Framework \Model \ResourceModel \Db \Collection \AbstractCollection
318
- ) {
319
- // Query optimization as SearchResultInterface doesn't have optimization for retrieving just ids
320
- $ idsArray = $ searchResult ->getAllIds ();
321
- } else {
322
- foreach ($ searchResult ->getItems () as $ item ) {
323
- /** @var $item \Magento\Framework\Api\Search\DocumentInterface */
324
- $ idsArray [] = $ item ->getId ();
325
- }
326
- }
327
- return $ idsArray ;
328
- }
329
304
}
Original file line number Diff line number Diff line change @@ -217,7 +217,19 @@ private function getDataProvider()
217
217
*/
218
218
private function getFilterIds ()
219
219
{
220
+ $ idsArray = [];
220
221
$ this ->applySelectionOnTargetProvider ();
221
- return $ this ->getComponent ()->getAllIds ();
222
+ if ($ this ->getDataProvider () instanceof \Magento \Ui \DataProvider \AbstractDataProvider) {
223
+ // Use collection's getItems for optimization purposes
224
+ return $ this ->getDataProvider ()->getAllIds ();
225
+ } else {
226
+ $ 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 ();
231
+ }
232
+ }
233
+ return $ idsArray ;
222
234
}
223
235
}
Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ public function getSearchCriteria()
172
172
/**
173
173
* Returns SearchResult
174
174
*
175
- * @return null
175
+ * @return AbstractCollection
176
176
*/
177
177
public function getSearchResult ()
178
178
{
@@ -279,4 +279,14 @@ public function setConfigData($config)
279
279
{
280
280
$ this ->data ['config ' ] = $ config ;
281
281
}
282
+
283
+ /**
284
+ * Retrieve all ids from Search Result
285
+ *
286
+ * @return int[]
287
+ */
288
+ public function getAllIds ()
289
+ {
290
+ return $ this ->getSearchResult ()->getAllIds ();
291
+ }
282
292
}
Original file line number Diff line number Diff line change @@ -125,11 +125,4 @@ public function prepareDataSource(array $dataSource);
125
125
* @return array
126
126
*/
127
127
public function getDataSourceData ();
128
-
129
- /**
130
- * Retrieve all ids from Search Result
131
- *
132
- * @return int[]
133
- */
134
- public function getAllIds ();
135
128
}
You can’t perform that action at this time.
0 commit comments