Something went wrong.
Never miss Magento tips, tricks, tutorials, and news.
Use the below code in your helper file.
Don’t forget to share this post with Magento Community via social media.
I would like to solve your problem.
Magento 2 offers various options to manage stock and inventory. One such option is a “Decrease Stock When Order is Placed” from Stores > Settings > Configuration > Catalog > Inventory > Stock Options that decreases the quantity in stock when order is placed if set to “Yes” and vice versa, for “No”.
Thank you for subscribing.
While working with such inventory-related tasks, a developer often needs to check the selected value of the default Magento 2 inventory management system.
Now, what if you want to add a column in your inventory records grid that displays the particular product’s salable quantity changes?
Method to Programmatically Check if Stock is Decreased When Order is Placed in Magento 2
You may need to do the same with the “Manage Stock” option too, and for that, you can refer to my solution here.
* Class IsStockDecreaseWhenOrderIsPlaced
class IsStockDecreaseWhenOrderIsPlaced extends AbstractHelper
* @var Configuration
* @var StoreManagerInterface
* IsStockDecreaseWhenOrderIsPlaced constructor.
* @param Configuration $inventoryConfiguration
* @param StoreManagerInterface $storeManager
* @param Context $context
public function __construct(Configuration $inventoryConfiguration, StoreManagerInterface $storeManager, Context $context)
$this->inventoryConfiguration = $inventoryConfiguration;
$this->storeManager = $storeManager;
* @return bool
* @throws NoSuchEntityException
public function isStockDecreaseWhenOrderIsPlaced()
Managing well-structured inventory is one of the most challenging and troublesome tasks for any E-commerce store owner. However, Magento 2 inventory management can’t be overlooked as it is one of the crucial factors that define the success of any business.
Check out the below code to do so.
Get Weekly Updates
If you have queries, feel free to ask in the Comments section below.
Magento 2 store owner applies various tactics to manage an accurate inventory that guarantees better control and planning of production and sales. Maintaining an inventory grid by generating an inventory report is one such tactic to handle inventory effectively.
You first have to programmatically check if stock is decreased when order is placed in Magento 2 and then set a necessary condition to display a record of stock set to “Yes” in the “Decrease Stock When Order is Placed” option.