Collection of Magento products, including for the disabled

I need to filter my magento product collection by disabled status. Magento by default ignores disconnected products when loading a collection.

So, I have two parts:

1 - How can I upload a collection to magento containing only disabled products? 2 - Why doesn't magento upload disabled products to collections for starters?

I use standard code to load the collection:

$collction = Mage::getModel('catalog/product')->getCollection()

it never downloads disabled products.

+5
source share
5 answers

If you use a flat product structure, then

$col = Mage::getModel('catalog/product')->getCollection();

will use a flat table (for example catalog_product_flat_1), and disabledproducts are not included in this table.

Use Flat Catalog Product "", : catalog-flat

.

+7

- ( ), , , ,

Mage::app()->getStore()->setConfig('catalog/frontend/flat_catalog_product', 0);

:

Mage::getModel('catalog/product')->getCollection()

, 1 , , , .

, .

+3

$collection = Mage::getResourceModel('catalog/product_collection')

.

. : https://magento.stackexchange.com/a/40001/32179

0

, , → joinTable ('cayaloginventory/stock_item', 'product_id = entity_id', array ('stock_status' = > 'is_in_stock'))

, , , , → addAttributeToFilter ('status', array ('eq' = > 1))... AVAILABLE.. if DISABLE change 2

        $collection = Mage::getModel('catalog/product')
                    ->getCollection()
                    ->joinTable( 'cataloginventory/stock_item', 'product_id=entity_id', array("stock_status" => "is_in_stock") )        
                    ->addAttributeToFilter('status', array('eq' => 2 ) );
0

, .

    $products = Mage::getModel('catalog/product')->getCollection()
        ->setStoreId(Mage::app()->getStore()->getId())
        ->addAttributeToFilter('status', '0');
-5

All Articles