Skip to content

Commit da6c8ea

Browse files
authored
MAGETWO-75524: Add Role column to admin user grid #10891
2 parents 1c6c624 + 9f5de14 commit da6c8ea

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,23 @@ protected function _construct()
2222
{
2323
$this->_init(\Magento\User\Model\User::class, \Magento\User\Model\ResourceModel\User::class);
2424
}
25+
26+
/**
27+
* Collection Init Select
28+
*
29+
* @return $this
30+
*/
31+
protected function _initSelect()
32+
{
33+
parent::_initSelect();
34+
$this->getSelect()->join(
35+
['user_role' => $this->getTable('authorization_role')],
36+
'main_table.user_id = user_role.user_id',
37+
[]
38+
)->join(
39+
['detail_role' => $this->getTable('authorization_role')],
40+
'user_role.parent_id = detail_role.role_id',
41+
['role_name']
42+
);
43+
}
2544
}

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)