3

I need to check the Product Salable Quantity of a product after a successful order to change one of the product´s attributes.

I keep getting the product salable quantity before It´s decremented. Where can I insert my code?

Thank you!

1

I think you need to use Controller fired after proper event.

Event can be fired before:

sales_quote_item_qty_set_after

Or

sales_quote_item_set_product

Model:

app/code/Magento/Quote/Model/Quote/Item.php 

Interesting explanation what is Magento Quote. https://stackoverflow.com/questions/4612100/what-is-a-magento-quote

List of events:

https://www.magestore.com/magento-2-tutorial/use-event-magento-2/

1

I am not sure about the Magento 2.3.X.

but for 2.2.X and 2.1.X versions, Stock deduction happen on order place from

Magento_CatalogInventory module.

The method registerProductsSale of Magento\CatalogInventory\Model\StockManagement is responsiable for stock deduction.

This method is called from Magento\CatalogInventory\Observer\SubtractQuoteInventoryObserver observer on

sales_model_service_quote_submit_before event.

And

Magento\CatalogInventory\Observer\CheckoutAllSubmitAfterObserver observer on

checkout_submit_all_after event.

For your requirement, you have to work on these two observer classes.

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.