Product collection with out of stock and In stock.
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
$collection = $this->_productCollectionFactory->create();
$collection->setFlag('has_stock_status_filter', true)
->addAttributeToSelect(array('*'))
->addFieldToFilter('visibility', 4)
->addCategoriesFilter(['eq' => $categories])
->addAttributeToSort('created_at', 'DESC')
->joinField('qty',
'cataloginventory_stock_item',
'qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left'
)->joinTable('cataloginventory_stock_item', 'product_id=entity_id', array('stock_status' => 'is_in_stock'))
->addAttributeToSelect('stock_status')
->load();
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
$collection = $this->_productCollectionFactory->create();
$collection->setFlag('has_stock_status_filter', true)
->addAttributeToSelect(array('*'))
->addFieldToFilter('visibility', 4)
->addCategoriesFilter(['eq' => $categories])
->addAttributeToSort('created_at', 'DESC')
->joinField('qty',
'cataloginventory_stock_item',
'qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left'
)->joinTable('cataloginventory_stock_item', 'product_id=entity_id', array('stock_status' => 'is_in_stock'))
->addAttributeToSelect('stock_status')
->load();