5 (100%) 6 votes

Here are the steps that you will follow in this How to get stock items list in Magento 2.3:

  1. Receiver stock items from Resource Model
  2. Get Resource Model of StockItem
  3. Build the select query

How to get stock items list in Magento 2

 get stock items list in Magento 2
get stock items list in Magento 2
  • In Magento 1, you can get stock items from collection by using command below

  • This command gets first 10 stock item records from database. It’s very easy.
  • However you can not use this solution on Magento 2. Try to take a look on the collection resource of Stock Item


  • You can see that the collection of StockItem doesn’t extends from AbstractCollection. Therefore we can’t use standard functions of collection to get data such as: setPageSize(), load().
  • So how can we get list of stock items in Magento2?
  • I have an easy solution that is receiving stock items from Resource Model.

  • The first, I get Resource Model of StockItem by using $objectManager. Then I build the select query using connection object. Finally, I fetch data from database using $select query.
  • Then after this i can get stock items list in Magento 2. Do I need to define this? Or just use the standard stockitem object and pass into an array? In any case, bit confused and need assistance structuring things properly.
  • That’s it. Adhere to every one of the introductions previously mentioned and you may complete the How to get stock items list in Magento 2.Hope my post can be helpful, thanks for reading. 

Your Magento website needs a powerful Magento ERP for stock control.


magento erp

How to Copy Custom Data from Quote Item to Order Item - Magento 2.3