Skip to content

Commit 81a542b

Browse files
committed
Fix alias in grid massaction for eav collections
1 parent 9fc254f commit 81a542b

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

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

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,36 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Backend\Block\Widget\Grid\Massaction;
89

10+
use Magento\Backend\Block\Template\Context;
11+
use Magento\Backend\Block\Widget;
12+
use Magento\Backend\Block\Widget\Grid\Column;
13+
use Magento\Backend\Block\Widget\Grid\ColumnSet;
914
use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface as VisibilityChecker;
1015
use Magento\Framework\Data\Collection\AbstractDb;
1116
use Magento\Framework\DataObject;
17+
use Magento\Framework\DB\Select;
18+
use Magento\Framework\Json\EncoderInterface;
19+
use Magento\Quote\Model\Quote;
20+
use function count;
21+
use function is_array;
1222

1323
/**
1424
* Grid widget massaction block
1525
*
1626
* @api
17-
* @method \Magento\Quote\Model\Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors
27+
* @method Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors
1828
* @method boolean getHideFormElement()
1929
* @deprecated 100.2.0 in favour of UI component implementation
2030
* @since 100.0.2
2131
*/
22-
abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
32+
abstract class AbstractMassaction extends Widget
2333
{
2434
/**
25-
* @var \Magento\Framework\Json\EncoderInterface
35+
* @var EncoderInterface
2636
*/
2737
protected $_jsonEncoder;
2838

@@ -39,13 +49,13 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
3949
protected $_template = 'Magento_Backend::widget/grid/massaction.phtml';
4050

4151
/**
42-
* @param \Magento\Backend\Block\Template\Context $context
43-
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
52+
* @param Context $context
53+
* @param EncoderInterface $jsonEncoder
4454
* @param array $data
4555
*/
4656
public function __construct(
47-
\Magento\Backend\Block\Template\Context $context,
48-
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
57+
Context $context,
58+
EncoderInterface $jsonEncoder,
4959
array $data = []
5060
) {
5161
$this->_jsonEncoder = $jsonEncoder;
@@ -118,15 +128,11 @@ private function isVisible(DataObject $item)
118128
* Retrieve massaction item with id $itemId
119129
*
120130
* @param string $itemId
121-
* @return \Magento\Backend\Block\Widget\Grid\Massaction\Item|null
131+
* @return Item|null
122132
*/
123133
public function getItem($itemId)
124134
{
125-
if (isset($this->_items[$itemId])) {
126-
return $this->_items[$itemId];
127-
}
128-
129-
return null;
135+
return $this->_items[$itemId] ?? null;
130136
}
131137

132138
/**
@@ -161,7 +167,7 @@ public function getItemsJson()
161167
*/
162168
public function getCount()
163169
{
164-
return sizeof($this->_items);
170+
return count($this->_items);
165171
}
166172

167173
/**
@@ -288,11 +294,11 @@ public function getGridIdsJson()
288294

289295
if ($collection instanceof AbstractDb) {
290296
$idsSelect = clone $collection->getSelect();
291-
$idsSelect->reset(\Magento\Framework\DB\Select::ORDER);
292-
$idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT);
293-
$idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET);
294-
$idsSelect->reset(\Magento\Framework\DB\Select::COLUMNS);
295-
$idsSelect->columns($this->getMassactionIdField(), 'main_table');
297+
$idsSelect->reset(Select::ORDER);
298+
$idsSelect->reset(Select::LIMIT_COUNT);
299+
$idsSelect->reset(Select::LIMIT_OFFSET);
300+
$idsSelect->reset(Select::COLUMNS);
301+
$idsSelect->columns($this->getMassactionIdField());
296302
$idList = $collection->getConnection()->fetchCol($idsSelect);
297303
} else {
298304
$idList = $collection->setPageSize(0)->getColumnValues($this->getMassactionIdField());
@@ -358,7 +364,7 @@ public function prepareMassactionColumn()
358364
{
359365
$columnId = 'massaction';
360366
$massactionColumn = $this->getLayout()->createBlock(
361-
\Magento\Backend\Block\Widget\Grid\Column::class
367+
Column::class
362368
)->setData(
363369
[
364370
'index' => $this->getMassactionIdField(),
@@ -378,7 +384,7 @@ public function prepareMassactionColumn()
378384
$gridBlock = $this->getParentBlock();
379385
$massactionColumn->setSelected($this->getSelected())->setGrid($gridBlock)->setId($columnId);
380386

381-
/** @var $columnSetBlock \Magento\Backend\Block\Widget\Grid\ColumnSet */
387+
/** @var $columnSetBlock ColumnSet */
382388
$columnSetBlock = $gridBlock->getColumnSet();
383389
$childNames = $columnSetBlock->getChildNames();
384390
$siblingElement = count($childNames) ? current($childNames) : 0;

0 commit comments

Comments
 (0)