aymeric69001 Posted October 20, 2022 Share Posted October 20, 2022 Hello, I would like to be able to create a new employee from Php code in Prestashop. I cannot find the corresponding piece of code, I looked into the controllers but nothing. Any idea ? Link to comment Share on other sites More sharing options...
Rhobur Posted October 21, 2022 Share Posted October 21, 2022 It is in classes/Employee.php. So, $employee = new Employee()... and so on.. 1 Link to comment Share on other sites More sharing options...
joseantgv Posted October 24, 2022 Share Posted October 24, 2022 (edited) From the install: $employee = new Employee(); $employee->id = 1; $employee->force_id = true; $employee->firstname = Tools::ucfirst($data['admin_firstname']); $employee->lastname = Tools::ucfirst($data['admin_lastname']); $employee->email = $data['admin_email']; $employee->setWsPasswd($data['admin_password']); $employee->last_passwd_gen = date('Y-m-d h:i:s', strtotime('-360 minutes')); $employee->bo_theme = 'default'; $employee->default_tab = 1; $employee->active = true; $employee->id_profile = 1; $employee->id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $employee->bo_menu = true; if (!$employee->add()) { $this->setError($this->translator->trans('Cannot create admin account', [], 'Install')); return false; } Edited October 24, 2022 by joseantgv (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now