I need to decrease purchased item saleable quantity with custom value (x* ordered_qty) after place order in Magento 2.Right now I'm using the following observer and class to update the quantity of purchased items.

Event Xml

    <event name="sales_order_place_after">
       <observer name="Update_customstock" instance="Company\MyMoudle\Observer\UpdateStock" />

Observer Class

class UpdateStock implements ObserverInterface

    public function execute(\Magento\Framework\Event\Observer $observer)

     $orderData = $observer->getEvent()->getOrder();
     $orderItems = $orderData->getAllVisibleItems();
               foreach($orderItems as $item) {
                      if($flag_variable) {
               $this->stockRegistry->updateStockItemBySku($item->getSku(), $stockItem);



But it's deceasing salable quantity double of my sent value and quantity also updating as sent value.

What I need

I need if the order is placed then only the decrease the salable quantity and once the shipment is created then decrease the quantity.

Please suggest any solution with a plugin or observer.


Use the following event global scope. Ex. VendorName/ModuleName/etc/events.xml


For Paypal payment method, use the following:

  • my mentioned event is working but as the explained issue is in salable qunitiy and product quntity value issue – Ashvini Marwal Nov 29 '19 at 9:48
  • Don't use sales_order_place_after event, this event will call every time when order will save. Ex. $order->save(). If you want something after the order place then use the above event that I answer. – Sohel Rana Nov 29 '19 at 10:15
  • Using your event getting the same issue.example SKU with qty 100 and 100 salable qty.i ordered 1 qty and stock effected as qty 99 and 98 saleable qty. I think my code is updating qty instead of salable qty.any idea? – Ashvini Marwal Nov 29 '19 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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