Magento 2.4.2 For some reason product stock is being set to 0 after an order is placed, regardless of quantity previously in stock or quantity ordered.

What could be causing this?

How can I debug where the error is coming from?

Is this likely to be a code error or some database error?

The site has recently been moved server, anything I should look out for here?

1 Answer 1


You can debug the problem by adding this event


The aim is, compare the quantity before and after place an order:

$stockItemOld = $this->stockItemRepository->get($stockItem->getId());
$beforeQty = $stockItemOld->getQty();

Then use this event cataloginventory_stock_item_save_after, to get the quantity after it changed:

$stockItem  = $observer->getEvent()->getItem();
  • Thanks, I will give that a try Commented Aug 20, 2021 at 15:42

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.