Skip to content

Commit 70180cd

Browse files
committed
MAGETWO-66402: Backward Incompatible Change
- fix integration test and add optimizations to use getAllIds where possible
1 parent d6df47f commit 70180cd

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

app/code/Magento/Ui/Component/MassAction/Filter.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function getCollection(AbstractDb $collection)
9999
throw new LocalizedException(__('Please select item(s).'));
100100
}
101101
}
102+
/** @var \Magento\Customer\Model\ResourceModel\Customer\Collection $collection */
102103
$idsArray = $this->getFilterIds();
103104
if (!empty($idsArray)) {
104105
$collection->addFieldToFilter(
@@ -220,14 +221,21 @@ private function getFilterIds()
220221
$idsArray = [];
221222
$this->applySelectionOnTargetProvider();
222223
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();
225226
} else {
226227
$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+
}
231239
}
232240
}
233241
return $idsArray;

app/code/Magento/Ui/DataProvider/AbstractDataProvider.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -281,24 +281,12 @@ public function setConfigData($config)
281281
}
282282

283283
/**
284-
* Retrieve all ids from Search Result
284+
* Retrieve all ids from collection
285285
*
286286
* @return int[]
287287
*/
288288
public function getAllIds()
289289
{
290-
$idsArray = [];
291-
$searchResult = $this->getSearchResult();
292-
if ($searchResult instanceof \Magento\Eav\Model\Entity\Collection\AbstractCollection
293-
|| $searchResult instanceof \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
294-
) {
295-
$idsArray = $searchResult->getAllIds();
296-
} else {
297-
foreach ($searchResult->getItems() as $item) {
298-
/** @var $item \Magento\Framework\Api\Search\DocumentInterface */
299-
$idsArray[] = $item->getId();
300-
}
301-
}
302-
return $idsArray;
290+
return $this->collection->getAllIds();
303291
}
304292
}

0 commit comments

Comments
 (0)