4

suppose in magento backend i have to 2 role one is admin, other is sales. just like admin set start page for admin is dashboard. I want to set sales order is to be start page for sales role user.i want to know is there is any way to assign a start page for different role in magento.

  • if login as a sales order tab only displayed right. your question is not clear – Magento 2 Sep 23 '15 at 9:56
  • supoose If login by sales team (role) his start page is manage product page in magento backend. This is i want to know. – Code Killer Sep 23 '15 at 10:43
  • I think dynamically we can't change but we can restrict permission – Magento 2 Sep 23 '15 at 10:48
  • I am taking about how can set or customize start page for different role user not about resource access.@LearningMagento – Code Killer Sep 23 '15 at 11:38
5

There is no native function too achieve this.

But you can use admin_session_user_login_success event for this.

To implement magento event observer refer this link

then add event in your config.xml file

<adminhtml>
    <events>
        <admin_session_user_login_success>
            <observers>
                <some_unique_handle>
                    <class>Namespace_Module_Model_Observer</class> 
                    <method>adminRedirect</method>
                    <type>singleton</type>
                </some_unique_handle>
            </observers>
        </admin_session_user_login_success>
    </events>
</adminhtml>

Then add this code in you observer file.

i.e., Path : app/code/{your-codepool}/{namespace}/{module}/Model/Observer.php

public function adminRedirect($observer)
{
    //get admin user id from observer
    $currentUserId = $observer->getuser()->getId();
    //get User Role
    $userRole = Mage::getModel('admin/user')->load($currentUserId)->getRole()->getRoleName();
    if($userRole == 'sales'){
             // If user role is sales then it'll redirect to the sales order list page
        $response = Mage::app()->getResponse();
        $response->clearHeaders()
                        ->setRedirect(Mage::helper("adminhtml")->getUrl('adminhtml/sales_order'))
                        ->sendHeadersAndExit();
    }
    return $this;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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