1

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 2

1

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.

1

As @robertino-vasilescu said, you must first declare your own Symfony service for PrestaShop.

GUIDE: Create and declare a new Symfony service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.