Search code examples
controlleroverridingprestashop

Override CustomerController of Prestashop in 17.6.1


I tried to add a new feature in my Prestashop 1.7.6 (allow to detect the change of group of a client since the backoffice).

I think I have to override a feature that I find in the CustomerController.php located in "src /PrestaShopBundle/Controller/Admin/Sell/Customer/CustomerController.php ".

How can I overload this controller, I tried to create a file in "override / controllers / admin" but it did not work ?


Solution

  • Code in /src folder can not be overrided:

    Understanding the “src” folder

    Overrides

    If you want to detect the change of group of a client, you can use hook actionCustomerBeforeUpdateGroup, which is called at classes/Customer:

    public function updateGroup($list)
    {
        Hook::exec('actionCustomerBeforeUpdateGroup', array('id_customer' => $this->id, 'groups' => $list));
        if ($list && !empty($list)) {
            $this->cleanGroups();
            $this->addGroups($list);
        } else {
            $this->addGroups(array($this->id_default_group));
        }
    }