gregp
gregp

Reputation: 61

Prestashop add customer method

I have a piece of code like this in init() method of class extending ModuleFrontController, but it doesn't work and i don't know why. I've checked definition in Customer class and only names, email and passwd is required, but nothing is happened in database. Prestashop 1.5.6.1

$customer = new Customer();
$customer->firstname = 'name';
$customer->lastname = 'lastname';
$customer->email = '[email protected]';
$customer->passwd = md5(time());
$customer->is_guest = 1;

$customer->add();

EDIT: This code works in postProcess() method in same class, so what is wrong..?

Upvotes: 1

Views: 1672

Answers (1)

CristiC
CristiC

Reputation: 22708

If you are placing the code under init() method - you are overriding the default init.

Try to call first the parent init and then add your code:

public function init()
{ 
    parent::init(); 
    ...

Upvotes: 1

Related Questions