Skip to content

Commit 8794ccb

Browse files
author
Oleksii Korshenko
authored
MAGETWO-69167: Admin Grid Mass action Select / Unselect All issue #9610 #9611
2 parents e5508b4 + 3bfcbd2 commit 8794ccb

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,16 @@ public function getGridIdsJson()
275275
if (!$this->getUseSelectAll()) {
276276
return '';
277277
}
278-
279278
/** @var \Magento\Framework\Data\Collection $allIdsCollection */
280279
$allIdsCollection = clone $this->getParentBlock()->getCollection();
281-
$gridIds = $allIdsCollection->clear()->setPageSize(0)->getAllIds();
282-
280+
281+
if ($this->getMassactionIdField()) {
282+
$massActionIdField = $this->getMassactionIdField();
283+
} else {
284+
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
285+
}
286+
287+
$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
283288
if (!empty($gridIds)) {
284289
return join(",", $gridIds);
285290
}

app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,14 @@ public function getGridIdsJson()
274274

275275
/** @var \Magento\Framework\Data\Collection $allIdsCollection */
276276
$allIdsCollection = clone $this->getParentBlock()->getCollection();
277-
$gridIds = $allIdsCollection->clear()->setPageSize(0)->getAllIds();
277+
278+
if ($this->getMassactionIdField()) {
279+
$massActionIdField = $this->getMassactionIdField();
280+
} else {
281+
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
282+
}
283+
284+
$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
278285

279286
if (!empty($gridIds)) {
280287
return join(",", $gridIds);

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ public function testGetGridIdsJsonWithoutUseSelectAll()
132132
public function testGetGridIdsJsonWithUseSelectAll(array $items, $result)
133133
{
134134
$this->_block->setUseSelectAll(true);
135-
135+
136+
if ($this->_block->getMassactionIdField()) {
137+
$massActionIdField = $this->_block->getMassactionIdField();
138+
} else {
139+
$massActionIdField = $this->_block->getParentBlock()->getMassactionIdField();
140+
}
141+
136142
$collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
137143
->disableOriginalConstructor()
138144
->getMock();
@@ -141,15 +147,13 @@ public function testGetGridIdsJsonWithUseSelectAll(array $items, $result)
141147
->method('getCollection')
142148
->willReturn($collectionMock);
143149

144-
$collectionMock->expects($this->once())
145-
->method('clear')
146-
->willReturnSelf();
147150
$collectionMock->expects($this->once())
148151
->method('setPageSize')
149152
->with(0)
150153
->willReturnSelf();
151154
$collectionMock->expects($this->once())
152-
->method('getAllIds')
155+
->method('getColumnValues')
156+
->with($massActionIdField)
153157
->willReturn($items);
154158

155159
$this->assertEquals($result, $this->_block->getGridIdsJson());

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ public function testGetGridIdsJsonWithoutUseSelectAll()
237237
public function testGetGridIdsJsonWithUseSelectAll(array $items, $result)
238238
{
239239
$this->_block->setUseSelectAll(true);
240+
241+
if ($this->_block->getMassactionIdField()) {
242+
$massActionIdField = $this->_block->getMassactionIdField();
243+
} else {
244+
$massActionIdField = $this->_block->getParentBlock()->getMassactionIdField();
245+
}
240246

241247
$collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
242248
->disableOriginalConstructor()
@@ -245,16 +251,13 @@ public function testGetGridIdsJsonWithUseSelectAll(array $items, $result)
245251
$this->_gridMock->expects($this->once())
246252
->method('getCollection')
247253
->willReturn($collectionMock);
248-
249-
$collectionMock->expects($this->once())
250-
->method('clear')
251-
->willReturnSelf();
252254
$collectionMock->expects($this->once())
253255
->method('setPageSize')
254256
->with(0)
255257
->willReturnSelf();
256258
$collectionMock->expects($this->once())
257-
->method('getAllIds')
259+
->method('getColumnValues')
260+
->with($massActionIdField)
258261
->willReturn($items);
259262

260263
$this->assertEquals($result, $this->_block->getGridIdsJson());

0 commit comments

Comments
 (0)