Jump to content

Admin Customer hook


sicine

Recommended Posts

hello everyone; 

 

i'm trying to add my customers to an other table in my database (the same prestashop database) so i tried to do it via hooks but its not working :( 

 

i don't know what's mistaken in my program 

 public function hookActionCustomerAccountAdd($params)
    {
    	$id_lang = $this->context->language->id;
	
        if ($customer instanceof Customer)
        {
        	$id_customer = $customer->id;
        	//the function that will add this customer to my table 
        }
    }

my prestashop version is 1.5.6.2 

please help, and thank you

Link to comment
Share on other sites

Yes, there are custom hooks in PrestaShop, you should check ObjectModel class and look at method add(), here you can find something like this:

// @hook actionObject*AddBefore
Hook::exec('actionObjectAddBefore', array('object' => $this));
Hook::exec('actionObject'.get_class($this).'AddBefore', array('object' => $this));

and this:

// @hook actionObject*AddAfter
Hook::exec('actionObjectAddAfter', array('object' => $this));
Hook::exec('actionObject'.get_class($this).'AddAfter', array('object' => $this));

So, you can hook your module into actionObjectCustomerAddAfter or actionObjectAddAfterCustomer and receive data in this way:

hookActionObjectCustomerAddAfter($params)
{
$customer = $params['object'];
}

In my opinion you can replace your entire code hooked into auth controller to this dynamic hook.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...