gennaris
gennaris

Reputation: 1612

Prestashop 1.7 - which hook to use in a module to get the used edited product quantity

I am building a simple module where I need to catch a backoffice quantity modification event (for product or variations) in real time and send the new quantity to an external API.

I am struggling in understanding which hook to use to get the actual user inserted quantity and not the "previous" product quantity.

If I use the static method StockAvailable::getQuantityAvailableByProduct inside the hookActionProductUpdate in my module, I am getting the original product quantity and not the new one, probably because the hook is called before the actual DB update.

Any clue ?

Upvotes: 0

Views: 1108

Answers (1)

ethercreation
ethercreation

Reputation: 1273

Try with: actionUpdateQuantity
You can pass the next parameters:

array(
  'id_product' => (int) Product ID,
  'id_product_attribute' => (int) Product attribute ID,
  'quantity' => (int) New product quantity
);

List of hook here : https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/

Upvotes: 0

Related Questions