Magento List all out of stock items

magento, php

Solution

Here is the function that I have been using

function getOutOfStockProducts()
{
        $products = Mage::getModel('catalog/product')
                ->getCollection()
                ->joinField(
                        'is_in_stock',
                        'cataloginventory/stock_item',
                        'is_in_stock',
                        'product_id=entity_id',
                        '{{table}}.stock_id=1',
                        'left'
                )
                ->addAttributeToFilter('is_in_stock', array('eq' => 0));

        return $products;
}

Problem

I am trying to make a cms page which lists all out of stock items. ``` protected function _getProductCollection() { $collection = Mage::getModel('catalog/product')->getCollection(); $collection = $this->_addProductAttributesAndPrices($collection) ->addStoreFilter() ->addAttributeToSort('entity_id', 'desc') //<b>THIS WILL SHOW THE LATEST PRODUCTS FIRST</b> ->addAttributeToFilter('stock_status', 0) ->setPageSize($this->get_prod_count()) ->setCurPage($this->get_cur_page()); $this->setProductCollection($collection); return $collection; } ``` But it is not working. It lists all items. What is the method to list all items which are qty =0 or is_in_stock =0?

Original source