For M2:
$collection = $this->productCollectionFactory->create();
//$collection->addAttributeToSelect('name');
$collection->addAttributeToFilter('status', 1);
you can inject product collection factory:
private $productCollectionFactory;
public function __construct(
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
) {
$this->productCollectionFactory = $productCollectionFactory;
}
Generated query will be:
SELECT
`e`.*,
IF(at_status.value_id > 0,
at_status.value,
at_status_default.value) AS `status`
FROM
`catalog_product_entity` AS `e`
INNER JOIN
`catalog_product_entity_int` AS `at_status_default` ON (`at_status_default`.`entity_id` = `e`.`entity_id`)
AND (`at_status_default`.`attribute_id` = '97')
AND `at_status_default`.`store_id` = 0
LEFT JOIN
`catalog_product_entity_int` AS `at_status` ON (`at_status`.`entity_id` = `e`.`entity_id`)
AND (`at_status`.`attribute_id` = '97')
AND (`at_status`.`store_id` = 1)
WHERE
(IF(at_status.value_id > 0,
at_status.value,
at_status_default.value) = '1')
By using ORM you dont need to bother about the status updated for you product against the STORE in table catalog_product_entity_int. It will generate query to check with this check already in it as you can see in above generated query its checking store value present in EAV table then use it else use default value.