Prestashop repository not found on hookActionUpdateQuantity after confirm the cart

Viewed 88

I developed a custom module and registered there a lot of hooks. I registered a hook for actionUpdateQuantity.

public function hookActionUpdateQuantity(array $params)
    {
        if ($params["id_product_attribute"] == 0) {
            $client = $this->getClient();
            PrestaShopLogger::addLog("ps->r2o hookActionUpdateQuantity:" . json_encode($params), 1, null, null, null, true);
            //check if product in synctable
            /** @var ReadyToOrderProductSyncRepository $productSyncRepo */
            $productSyncRepo = $this->get(
                'prestashop.module.readytoordersync.repository.ready_to_order_product_sync_repository'
            );
            $r2Product = $productSyncRepo->findOneBy(['id' => $params["id_product"]]);
            if ($r2Product != null) {
                $client->updateProductQuantity($r2Product, $params["quantity"]);
            } else {
                PrestaShopLogger::addLog("ps->r2o Update Quantity prestashop product not found:" . json_encode($params), 2, null, null, null, true);
            }
        }

    }

This hook will be called in different situations. If it is called after modify a product everything works fine.

If it is called after confirm the shopping cart I retrieve following error:

Exception on hook actionUpdateQuantity for module.
You have requested a non-existent service
\"prestashop.module.readytoordersync.repository.ready_to_order_product_sync_repository\".

Prestashop version: 1.7.7.5

2 Answers

This is a service that should be added by your third party module having the namespace readytoordersync. If this is your custom module investigate where you call this service from.

Related