Search code examples
phpweb-servicessymfonyprestashopprestashop-1.6

Prestashop synchronize with ERP


I managed to update Prestashop with data sent from my ERP made with PHP using the webservice that offers prestashop, but now I need to know how to detect changes in prestashop bd to update my ERP with those changes.

Can anyone offer me an introduction to the subject or some way of doing this? Thank you


Solution

  • Everything depends on what informations you want to retrieve from Prestashop.

    You'll have to write a module which uses Prestashop Hook system.

    For example if you want to inform your ERP about a new customer registration:

    <?php
    
    class ERPConnect extends Module
    {
    
        public function install()
        {
            return parent::install() && $this->registerHook('actionObjectCustomerAddAfter'); // This hook is called in /classes/ObjectModel.php > method add()
        }
    
        public function hookActionObjectCustomerAddAfter($params)
        {
            $customer = $params['object'];
            MyErpConnector::sendNewCustomer($customer);
        }
    }
    

    There are many hooks but there is no official list. You'll have to dig into the different classes (in /classes/) to find those you want to use.

    Note that for any classes you can call the hook: actionObject[Object Name]AddAfter.