Skip to content

Commit 3445928

Browse files
committed
Add Role column to admin user grid
1 parent 659a245 commit 3445928

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

app/code/Magento/User/Model/ResourceModel/User/Collection.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,18 @@ protected function _construct()
2222
{
2323
$this->_init(\Magento\User\Model\User::class, \Magento\User\Model\ResourceModel\User::class);
2424
}
25+
26+
public function _initSelect()
27+
{
28+
parent::_initSelect();
29+
$this->getSelect()->join(
30+
['user_role' => $this->getTable('authorization_role')],
31+
'main_table.user_id = user_role.user_id',
32+
[]
33+
)->join(
34+
['detail_role' => $this->getTable('authorization_role')],
35+
'user_role.parent_id = detail_role.role_id',
36+
['role_name']
37+
);
38+
}
2539
}

app/code/Magento/User/view/adminhtml/layout/adminhtml_user_grid_block.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@
7474
<argument name="index" xsi:type="string">email</argument>
7575
</arguments>
7676
</block>
77+
<block class="Magento\Backend\Block\Widget\Grid\Column" as="role_name">
78+
<arguments>
79+
<argument name="header" xsi:type="string" translate="true">Role</argument>
80+
<argument name="index" xsi:type="string">role_name</argument>
81+
<argument name="filter_index" xsi:type="string">detail_role.role_name</argument>
82+
</arguments>
83+
</block>
7784
<block class="Magento\Backend\Block\Widget\Grid\Column" as="is_active">
7885
<arguments>
7986
<argument name="header" xsi:type="string" translate="true">Status</argument>

0 commit comments

Comments
 (0)