@@ -82,10 +82,11 @@ public function getComponent()
82
82
* Adds filters to collection using DataProvider filter results
83
83
*
84
84
* @param AbstractDb $collection
85
+ * @param bool $limit for limiting maximum amount of query results
85
86
* @return AbstractDb
86
87
* @throws LocalizedException
87
88
*/
88
- public function getCollection (AbstractDb $ collection )
89
+ public function getCollection (AbstractDb $ collection, $ limit = true )
89
90
{
90
91
$ selected = $ this ->request ->getParam (static ::SELECTED_PARAM );
91
92
$ excluded = $ this ->request ->getParam (static ::EXCLUDED_PARAM );
@@ -99,7 +100,7 @@ public function getCollection(AbstractDb $collection)
99
100
}
100
101
}
101
102
/** @var \Magento\Customer\Model\ResourceModel\Customer\Collection $collection */
102
- $ idsArray = $ this ->getFilterIds ();
103
+ $ idsArray = $ this ->getFilterIds ($ limit );
103
104
if (!empty ($ idsArray )) {
104
105
$ collection ->addFieldToFilter (
105
106
$ collection ->getIdFieldName (),
@@ -212,22 +213,27 @@ private function getDataProvider()
212
213
213
214
/**
214
215
* Get filter ids as array
215
- *
216
+ * @param bool $limit
216
217
* @return int[]
217
218
*/
218
- private function getFilterIds ()
219
+ private function getFilterIds ($ limit = true )
219
220
{
220
221
$ idsArray = [];
221
222
$ this ->applySelectionOnTargetProvider ();
222
223
if ($ this ->getDataProvider () instanceof \Magento \Ui \DataProvider \AbstractDataProvider) {
223
224
// Use collection's getAllIds for optimization purposes.
224
225
$ idsArray = $ this ->getDataProvider ()->getAllIds ();
225
- } else {
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 ($ limit ){
229
+ // Use compatible search api getItems when searchResult is not a collection.
230
+ foreach ($ searchResult ->getItems () as $ item ) {
231
+ /** @var $item \Magento\Framework\Api\Search\DocumentInterface */
232
+ $ idsArray [] = $ item ->getId ();
233
+ }
234
+ }else {
235
+ //Grab all selected even if they are not on the current page.
236
+ $ idsArray = $ searchResult ->getAllIds ();
231
237
}
232
238
}
233
239
return $ idsArray ;
0 commit comments