Force customer login

piaoling  2011-08-05 15:40:27

I had a requirement like customer support will able to login as any customer. Here is the code snippet i used to force customer support to login as normal user.

1 $customerId = (int) $this->getRequest()->getParam('id');
2 $customer   = Mage::getModel('customer/customer')
3                   ->load($customerId);
4  
5 $userSession = Mage::getSingleton('customer/session');
6 $userSession->setCustomer($customer);
7 Mage::dispatchEvent('customer_login', array('customer'=>$customer));
8  
9 $this->getResponse()->setRedirect(Mage::getUrl('customer/account'));

 

类别 :  magento(258)  |  浏览(3751)  |  评论(0)
发表评论(评论将通过邮件发给作者):

Email: