Get out of stock product collection in magento 2

By default magento filters only in stock products in collection. We have to set the in stock filter as false.
$productCollection = $_objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');

$collection = $productCollection->create()->setFlag('has_stock_status_filter', false)->load();

Comments

Post a Comment