Skip to content

Commit

Permalink
Fixes grid column type concat (#4476)
Browse files Browse the repository at this point in the history
* Fixes grid column type `concat`

* removed useless test
  • Loading branch information
sreichel authored Jan 15, 2025
1 parent cb9305a commit 1cca899
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ public function addColumnDefaultData(array $column): array
{
$config = $this->getConfigDefaultColumnSettings();
$columnHasIndex = array_key_exists('index', $column);
if ($columnHasIndex && array_key_exists($column['index'], $config['index'])) {
if ($columnHasIndex &&
!is_array($column['index']) &&
array_key_exists($column['index'], $config['index'])
) {
$column += $config['index'][$column['index']];
}

Expand Down
3 changes: 3 additions & 0 deletions app/code/core/Mage/Adminhtml/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@
<sortable>false</sortable>
<width>40</width>
</action>
<concat>
<separator> </separator>
</concat>
<currency>
<align>right</align>
<index>price</index>
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/Mage/Adminhtml/Block/Widget/GridTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ public function provideAddColumnDefaultData(): Generator
'type' => 'text',
],
];
yield 'index array - ref #4475' => [
[
'index' => ['firstname', 'lastname'],
'type' => 'concat',
'separator' => ' ',
],
[
'index' => ['firstname', 'lastname'],
'type' => 'concat',
],
];
yield 'type action' => [
[
'type' => 'action',
Expand Down

0 comments on commit 1cca899

Please sign in to comment.