Question

I need to make happen following:

  • I have five admins that can only access "Customer" area
  • They are adding customers to buy in the front end
  • Customers are divided into five groups

I need to make the process of adding users so it excludes choosing to which group customer is added but it needs to be added automatically based on which admin is adding the user.

Was it helpful?

Solution

Create a custom module with an observer for adminhtml_customer_save_after

In config.xml

<events>
    <adminhtml_customer_save_after>
        <observers>
            <magepal_admincustomergroup>
                <type>model</type>                           
                    <class>admincustomergroup/observer</class>
                    <method>saveAdminCustomerGroup</method>
            </magepal_admincustomergroup>
        </observers>
    </adminhtml_customer_save_after>
</events>

In your observer

public function saveAdminCustomerGroup(Varien_Event_Observer $observer)
{

    $customer = $observer->getCustomer();

    $user = Mage::getSingleton('admin/session');
    $userId = $user->getUser()->getUserId();

    //check current admin user info and set customer group
    // $customer->setData( 'group_id', 5 ); 
    // save customer

    // may want to check if customer already assign to a group
}

OTHER TIPS

Yo can create an observer for the event adminhtml_customer_save_after, see the logged user and act consequently.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top