sicine Posted August 26, 2014 Share Posted August 26, 2014 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 More sharing options...
Krystian Podemski Posted August 26, 2014 Share Posted August 26, 2014 (edited) In AuthController.php you had: Hook::exec('actionCustomerAccountAdd', array( '_POST' => $_POST, 'newCustomer' => $customer )); So you should assign this values this way: $customer = $params['newCustomer']; $postDatas = $params['_POST']; Edited August 26, 2014 by Krystian Podemski (see edit history) 1 Link to comment Share on other sites More sharing options...
sicine Posted August 26, 2014 Author Share Posted August 26, 2014 Hello krystian thank you so much for the reply, and it works now well this hook is a front-end one, is there a back end hook in which I can do the same think ??? and thank you again Link to comment Share on other sites More sharing options...
Krystian Podemski Posted August 27, 2014 Share Posted August 27, 2014 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. 1 Link to comment Share on other sites More sharing options...
sicine Posted August 27, 2014 Author Share Posted August 27, 2014 thank you so much you just saved my life , sorry my reply is late .. thank's again for the help and viva prestashop community 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