Before I start, I have read over a dozen stack exchange posts related to this, all of them suggesting pretty much what I'm using, which doesn't work for me hence the question.
I want to get all disabled products with quantity > 0 and for this I am using the following:
$products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('name', 'sku', 'qty', 'status')
->addStoreFilter($this->storeId)
->joinField('qty',
'cataloginventory/stock_item',
'qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left')
->addAttributeToFilter('qty', array('gt' => 0))
->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED));
// debug
$query = $products->getSelect()->__toString();
The query shows as this with no where clause:
SELECT 1 AS `status`, `e`.`entity_id`, `e`.`type_id`, `e`.`attribute_set_id`, `e`.`name`, `at_qty`.`qty` FROM `catalog_product_flat_1` AS `e` LEFT JOIN `cataloginventory_stock_item` AS `at_qty` ON (at_qty.`product_id`=e.entity_id) AND (at_qty.stock_id=1)
My results show everything in the store i.e with qty = 0 or any other qty and with any status.
I've tried every variation I can think of and find on stack exchange to no affect.
I would be grateful if anyone has any answer for this.
Many thanks