How to login as a customer from Magento admin?
One important feature that Magento is missing is the ability for admin user to login as customer. However there is no important reason why such feature would be required since admin users can change customer info from the admin area and can create orders from admin area for customers. One possible reason can be for more precise debugging of issues which customers report with their customer accounts. Often there are situations where customer has some issues while placing orders or making operations from the My Account section. At this point of time, ability for admin to login as a customer and see what is wrong becomes very useful. You can make universal password logic, but the method involves heavy security risks. Here is a way of how to create a simple extension for logging in as a customer from Magento admin. So read through to know how to login as a customer from Magento admin.
It is already known that Magento supports multi-websites functionality. Now take the System > Configuration > Customers > Customer Configuration > Account Sharing Options > Share Customer Accounts option into consideration. This option can be set to either Per Website value or Global. If the Share Customer Accounts option is set to Global that means that customer can log into any existing website which is powered by running Magento instance. However, on the other hand if Share Customer Accounts option is set to Per Website that means that customer can log only into websites in which he or she has registered (signed up) in. We have to stick to this simple rule in order to keep things functioning in the right way. You can easily check via a line of code if Share Customer Accounts option is set to Per Website and if it’s not Per Website then its Global.
The way in which we will implement the functionality is by adding the Login as Customer button on the customer edit screen. There are several different ways to add the button on that screen. The developer usually rewrites the block that renders the screen and adds the functionality through it. Here is an example how to add a button to customer edit screen via event/observer approach. The event in which we are interested is adminhtml_widget_container_html_before, triggered under adminhtml.Next,it is required to define two controllers Inchoo_LoginAsCustomer_Adminhtml_Inchoo_LoginAsCustomerController and Inchoo_LoginAsCustomer_CustomerController.The reason for doing so is to do some juggling between two.
We need to execute the following a line of code in order to login the customer. However, executing this code from the admin area won’t do a thing. One needs to execute it from frontend area, which is the frontend controller. You have to use your admin controller to encrypt the data about the customer you want to login and send that data to frontend controller in order to keep things safe. Once triggered, frontend controller will try to decrypt the data passed to it, and it will log in the proper customer, if successful .The admin controller will also read the proper website base url config option keeping the multi-website functionality in mind.