Skip to main content
2 of 2
added 6 characters in body
Ajwad Syed
  • 1.6k
  • 28
  • 62

How to get product Quantity in Magento 2

I need to retrieve product quantity, I found that, the interfaces we used before to get product quantity are deprecated, these are:

\Magento\CatalogInventory\Api\StockStateInterface $stockItem

And,

\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry

Below link says StockStateInterface is replaced with Multi Source Inventory but I cannot see a function returning product quantity in it.

https://www.magentoextensions.org/documentation/interface_magento_1_1_catalog_inventory_1_1_api_1_1_stock_state_interface.html

Is there some other way to get product quantity? I don't want to use deprecated code.

Ajwad Syed
  • 1.6k
  • 28
  • 62