In magento 1 ,
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('status', 1); // enabled
$products->addAttributeToFilter('type_id', 'simple');
//$products->addAttributeToFilter('sku', array('1234')); //for testing purposes
$products->addAttributeToSelect('*');
Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($products);
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($products);
$prodIds = $products->getAllIds();
I need to filter product collection with Is_salable() filter in magento2
Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($products);
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($products);
How to do this in magento2?
$collection = $this->_categoryFactory->create()->load($categoryId) // Load Category Products by CategoryID
->getProductCollection()
->addAttributeToSelect('sku')
->setStoreId($storeId)
->addAttributeToFilter('color_family', array('eq' => $optionId))
->addAttributeToFilter('visibility', MagentoCatalogModelProductVisibility::VISIBILITY_BOTH)
->addAttributeToFilter('status', MagentoCatalogModelProductAttributeSourceStatus::STATUS_ENABLED);
Thanks