samoht1191 Posted June 15, 2022 Share Posted June 15, 2022 Hi there, I'm kind of new to Prestashop module development, but I have some solid background with PHP and also with symphony. I'm currently facing a strange issue that I just can't explain to myself. Here's the thing: I need to link my module to the hook for customer creation and update, and as I need to catch that in both FO and BO, I'm using the objectCustomerAddAfter and objectCustomerUpdateAfter. However, I can not transplant it in the BO because it's not in the dropdown list of available hooks. In this list I correctly see the other hooks I'm using in my module (objectCustomerAddAfter, OrderEdited, OrderStatusUpdate, addWebserviceResources) but not this one! Weirder thing : if I just change $this->registerHook('objectCustomerUpdateAfter') ... public function hookActionObjectCustomerUpdateAfter($params){...} to $this->registerHook('objectCustomerUpdateBefore') ... public function hookActionObjectCustomerUpdateBefore($params){...} in my module main php file, I see it appears in the transplant list, but never happens with objectCustomerUpdateAfter 😅 Do you have some idea? Thanks ! Link to comment Share on other sites More sharing options...
knacky Posted June 15, 2022 Share Posted June 15, 2022 (edited) ....registerHook->('ActionObjectCustomerUpdateAfter'); action<AdminControllerClassName><Action>After https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/ Edited June 15, 2022 by knacky (see edit history) Link to comment Share on other sites More sharing options...
samoht1191 Posted June 16, 2022 Author Share Posted June 16, 2022 Thanks knacky for your reply. However, I tried your suggestion with no success, and when trying to add the 'action' prefix to the 'CustomerUpdateBefore' hook that used to work, it doesn't show up anymore in the list. Link to comment Share on other sites More sharing options...
knacky Posted June 16, 2022 Share Posted June 16, 2022 PS version ? PHP version ? Link to comment Share on other sites More sharing options...
samoht1191 Posted June 16, 2022 Author Share Posted June 16, 2022 I'm sorry, I put the PS version in tags, maybe it's not really eye catching. PS version is 1.7.8.6 and PHP version is 7.4.29. Link to comment Share on other sites More sharing options...
knacky Posted June 16, 2022 Share Posted June 16, 2022 (edited) public function install() { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } return ( parent::install() && $this->registerHook('actionObjectCustomerUpdateAfter') ); } public function uninstall() { return ( parent::uninstall() && $this->unregisterHook('actionObjectCustomerUpdateAfter') ); } public function hookActionObjectCustomerUpdateAfter($params) { $idCustomer = (int)$params['object']->id; $customer = new Customer((int)$idCustomer); $customerFirstname = $customer->firstname; $customerLastname = $customer->lastname; /* deactive customer, add siret, add ape */ $db = Db::getInstance(); $db->update('customer', array( 'active' => 0, 'ape' => pSQL('12345678'), 'siret' => pSQL('XA123456') ), 'id_customer = '.(int)$idCustomer ); } Edited June 16, 2022 by knacky (see edit history) Link to comment Share on other sites More sharing options...
samoht1191 Posted June 17, 2022 Author Share Posted June 17, 2022 Thanks for the example, but didn't really help as this is almost exactly what I have in my code. Finnally I figured it out by uninstalling completely the module, unregistering hooks manually and installing it again and the CustomerUpdateAfter eventually showed up. 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