Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento load product collection including disabled products

Tags:

magento

I need to filter a magento product collection by disabled status. Magento seems to by default ignore disabled products when loading the collection.

So there are two parts to my question:

1 - How can i load a collection in magento containing only disabled products? 2 - Why is magento not loading disabled products in the collection to begin with?

I am using standard code to load the collection:

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

this never loads disabled products.

like image 657
Marty Wallace Avatar asked Feb 26 '13 17:02

Marty Wallace


1 Answers

If you use the product flat structure, then

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

will use the flat table (eg. catalog_product_flat_1), and disabled products are not part of that table.

Change the config Use Flat Catalog Product to "NO" and you will have all products in the collection: catalog-flat

It will load all products this way.

like image 159
Péter Gulyás Avatar answered Oct 31 '22 05:10

Péter Gulyás