DevelopperK Posted March 29, 2023 Share Posted March 29, 2023 (edited) Hello ! I'm using prestashop 1.7.8.8, i tried to add a new customer in the database "manualy" without using BO but only name and lastname changed and then i want to try again but nothing happened. This is my code I hope i get some help. Edited March 30, 2023 by DevelopperK (see edit history) Link to comment Share on other sites More sharing options...
Eutanasio Posted April 22, 2023 Share Posted April 22, 2023 can you paste the code instead of an image? that way we may be able to copy and work on it to provide possible solutions Link to comment Share on other sites More sharing options...
ventura Posted April 22, 2023 Share Posted April 22, 2023 It would be better practice to create a function /** * @return bool * * @throws PrestaShopException */ public function createNewCustomer() { /** @var Hashing $crypto */ $crypto = ServiceLocator::get(Hashing::class); // create a new customer $customer = new Customer(); $customer->id_gender = 1; $customer->lastname = 'Jane'; $customer->firstname = 'Meldrum'; $customer->email = 'meldrum@example.com'; $customer->passwd = $crypto->hash('customer_password'); // generate encrypted password $customer->active = true; if ($customer->save() == false) { return false; } unset($customer); return true; } It would also be recommended to add the namespaces in the controller before the class class ProfileExpertProfileExpertfModuleFrontController extends ModuleFrontController use PrestaShop\PrestaShop\Adapter\ServiceLocator; use PrestaShop\PrestaShop\Core\Crypto\Hashing; Link to comment Share on other sites More sharing options...
DevelopperK Posted April 30, 2023 Author Share Posted April 30, 2023 Thank you very much for your replies ! i put the save method in postprocess function and it did work 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