2

enter image description here

I can filter the adminhtml users grid to only show users with a specific role ID as code in

\app\code\local\Mage\Adminhtml\Block\Permissions\User\grid.php

=> for collection

 protected function _prepareCollection()
{

    $collection = Mage::getResourceModel('admin/user_collection');
    $collection->getSelect()->join(array('ar' =>'admin_role'),'ar.user_id = admin_user.user_id')
    ->reset('columns')->columns(array('role_id'));
    $this->setCollection($collection);
    return parent::_prepareCollection();

}

=>and for add column

 protected function _prepareColumns()
{
  parent::_prepareColumns(); 
    $this->addColumn('role_id', array(
        'header'    =>Mage::helper('adminhtml')->__('Role ID'),
        'index'     =>'role_id',
        'align'     => 'right',
        'width'    => '50px'
    ));

But still not getting roll id in column ..

1 Answer 1

3

Replace following code.

$collection->getSelect()->join(
            array('ar' =>'admin_role'),
            'ar.user_id = main_table.user_id',
            array('role_id')
        );

So _prepareCollection looks like:

protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel('admin/user_collection');
        $collection->getSelect()->join(
            array('ar' =>'admin_role'),
            'ar.user_id = main_table.user_id',
            array('role_id')
        );
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.