bpierini Posted July 20, 2012 Share Posted July 20, 2012 Hi all, I am very new to prestashop, so I apologize if I'm missing other concepts in the software with my question below. I am creating a module that must integrate with an ERP software. To start the project, I created a module that intercepts the creation of client and sends a command to my ERP software to include the same customer. But now I must finish with the CRUD and my question is: How to intercept the deletion and modification in the data of a customer by AdminCustomers, so I can send the same commands for my ERP software? I tried to override this AdminCustomers code below to try to prevent the prestashop delete a customer, but I realized I'm not in the right place, because the client was excluded ... public function postProcess(){ .......code........ elseif (Tools::isSubmit('delete'.$this->table) AND $this->tabAccess['delete'] === '1') { switch (Tools::getValue('deleteMode')) { case 'real': // commenting this block to try avoid the deletion //$this->deleted = false; //Discount::deleteByIdCustomer((int)(Tools::getValue('id_customer'))); break; case 'deleted': // commenting this block to try avoid the deletion //$this->deleted = true; break; default: echo $deleteForm; if (isset($_POST['delete'.$this->table])) unset($_POST['delete'.$this->table]); if (isset($_GET['delete'.$this->table])) unset($_GET['delete'.$this->table]); break; } } elseif (Tools::isSubmit('submitDel'.$this->table) AND $this->tabAccess['delete'] === '1') { switch (Tools::getValue('deleteMode')) { case 'real': // commenting this block to try avoid the deletion //$this->deleted = false; //foreach (Tools::getValue('customerBox') as $id_customer) //Discount::deleteByIdCustomer((int)($id_customer)); break; case 'deleted': // commenting this block to try avoid the deletion //$this->deleted = true; break; default: echo $deleteForm; if (isset($_POST['submitDel'.$this->table])) unset($_POST['submitDel'.$this->table]); if (isset($_GET['submitDel'.$this->table])) unset($_GET['submitDel'.$this->table]); break; } } .......code........ } What part of the code is responsible for deleting and changing data from a client? Does anyone have a better idea to give me, or a different way to do this that explained? I'm using Prestashop 1.4.8.2 Thank you! Link to comment Share on other sites More sharing options...
math_php Posted July 22, 2012 Share Posted July 22, 2012 Hi I would make an override of customer's class with just the following code : class CustomerCore extends ObjectModel { public function delete(){ return false; } } This will output an error message that the deletion was not made, if someone tried to delete a customer. But if you search and destroy also the displayed option it will be safer. Good dev Link to comment Share on other sites More sharing options...
bellini13 Posted July 22, 2012 Share Posted July 22, 2012 I agree that you would want to override the Customer class, but not in the way above. You would likely want to override the update/save and delete functions, and try to determine what values have been changed. Or perhaps when anything has changed, you just do a complete refresh of all the customer information. Link to comment Share on other sites More sharing options...
math_php Posted July 22, 2012 Share Posted July 22, 2012 Yes bellini13 my solution deals only with the deletion of a customer, not the whole synchronization needed to exchange with the erp. Also the overrided delete function could mark the customer as not active in place of just avoiding the delete operation. The dustbin for customer deletion could be removed. 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