Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Find Out of Stock Products With Inventory

Tags:

magento

In my Magento store I sometimes forget to select 'In Stock' from the dropdown after adding new inventory to an out of stock item.

Is it possible to somehow get a list of all products which have inventory but as tagged as "Out of Stock"?

like image 557
a1anm Avatar asked Jul 19 '10 17:07

a1anm


People also ask

How do I show out of stock products in Magento 2?

To show Magento 2 product that is out of stock status you need to do the following: Log in to the Admin Panel and go to Stores>Configuration>Catalog>Inventory. Open the Stock Options dropdown. Set Yes in the Display Out of Stock Products option if you want to display out-of-stock products in your Magento 2 store.

How can I tell if an item is out of stock in Magento 2?

Use the Magento\CatalogInventory\Api\StockRegistryInterface class to fetch product stock status. Call method with a required parameter, $productId = 1; echo $result = $this->getStockStatus($productId); A result will be true if product qty greater than 0 or Stock Status set to In stock from the admin panel.

Does Magento manage inventory?

Inventory Management for Adobe Commerce and Magento Open Source gives you the tools to manage your product inventory. Merchants with a single store to multiple warehouses, stores, pickup locations, drop shippers, and more can use these features to maintain quantities for sales and handle shipments to complete orders.


1 Answers

If you are able to script something real quick.

$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('is_in_stock', 0)
->addAttributeToFilter('qty', array("gt" => 0));

Sadly I can't seem to remember how to put in the >0 in a way that is supposed to work. Maybe someone can comment on that.

What you can do with $products is run it through a foreach loop and then set the is_in_stock to the value of 1 and you should be in business.

like image 194
Josh Pennington Avatar answered Sep 30 '22 13:09

Josh Pennington