Handling product quantity is the most essential factor for multi-store inventory management especially when your store has more than one warehouse or source.
However, today’s market is more customer-centric than ever, and having a more thorough inventory strategy to manage inventory in your warehouse is becoming a necessity.
Suppose, you have one source in Chicago and the other in New York and you have the same product at both sources. Now, what if you want to keep track of an inventory of both sources? How can you find out the quantity of a particular product at both warehouses? How can you alert the admin about low product quantity?
Method to Get Product Quantity Information in Magento 2
Use the below code in your helper file.
* Class GetQuantityInformationForProduct
class GetQuantityInformationForProduct extends AbstractHelper
* @var GetQuantityInformationPerSource
* GetQuantityInformationForProduct constructor.
* @param GetQuantityInformationPerSource $getQuantityInformationPerSource
* @param Context $context
public function __construct(GetQuantityInformationPerSource $getQuantityInformationPerSource, Context $context)
$this->getQuantityInformationPerSource = $getQuantityInformationPerSource;
* @param $productSku
* @return array
public function getQuantityInformationForProduct($productSku)
Thank you for subscribing.
 => Array
[source_code] => source_2
[quantity_per_source] => 1215
[source] => New York
[status] => 1
 => Array
[source_code] => source_3
[quantity_per_source] => 12297
[source] => Chicago
[status] => 1
In such a case, use the below method to get product quantity information in Magento 2.
Once you have set this code, you get the array data as shown below:
The above log displays that 1215 quantity is there at the New York and 12297 quantity is there at Chicago.
Feel free to share the solution with Magento Community via social media.
If you have any doubts regarding this post, just mention them in the Comments section below.
Never miss Magento tips, tricks, tutorials, and news.
Get Weekly Updates
I would be happy to help.
Something went wrong.
One of the most troublesome jobs in eCommerce store management is to control all the data in the inventory and get the required one when needed. Every store owner encounters inventory management challenges at one point or another.