PrestaCraft on Facebook

Please like our page on Facebook to get notifications about new tutorials :)



For some people the way of logging in to BackOffice in PrestaShop might be quite uncomfortable, because everytime they have to type (long!) email address (instead login).

This tutorial shows the necessary changes to make login via username to BackOffice possible.

Before any changes, please remember to do a backup of all your files! I don’t take any responsibility for presumable inconveniences or bugs which may occur after those modifications.

Firstly, you need to store somewhere your new login field. I think the best place for it is adding a new column in the ps_employee table. Go to your phpMyAdmin and execute this SQL command.

Then, find in that table a row with person, who you want to set login and add it.

Edit: /adminXXX/themes/default/template/controllers/login/content.tpl

Now it’s time to edit a login form.


Replace with:

Edit: /controllers/admin/AdminLoginController.php

Next, let’s modify AdminLogin Controller. You have to add there our new field called loginfield and remove email address validation.


Replace with:

There is also a need to replace the function which checks user credentials. Create call to a new function getByLogin.


Replace with:

Edit: /classes/Employee.php

Now, extend your Employee class by adding a new function getByLogin.


Add after:

Edit: /js/admin/login.js

The last thing to do is modifying the required field in JavaScript.


Replace with:

Set overrides

Last and very important thing is to move all Your changes to override/ directory.
1. Copy and paste files:

Source Destination
controllers/admin/AdminLoginController.php override/controllers/admin/AdminLoginController.php
classes/Employee.php override/classes/Employee.php

2. Replace in DESTINATION files:
class AdminLoginControllerCore extends AdminController replace with class AdminLoginController extends AdminLoginControllerCore
class EmployeeCore extends ObjectModel replace with class Employee extends EmployeeCore

3. Purge cache:
Remove /cache/class_index.php file.

Add a comment

Leave a comment

Your email address will not be published.