1

I have a custom script to update prices and stock automaticly.

To get all products attributes I use:

$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*');

I saw that other people noticed that not all products-id are loaded. This I figured out. Because the disabled products are not in de EAV flat tables.

  1. So my question, how to I get the same output with the collection above but then with the disabled products included?
  2. And also is there another way to load all products id and attributes by name e.g. foreach product, id, price, stock.... without loading all the overhead
0

When you are using Flat Catalog Product options it will return only enable product collection.check below code for more understanding

Mage_Catalog_Model_Product_Flat_Indexer::updateProductStatus()

public function updateProductStatus($productId, $status, $store = null)
{
    if (is_null($store)) {
        foreach (Mage::app()->getStores() as $store) {
            $this->updateProductStatus($productId, $status, $store->getId());
        }
        return $this;
    }

    if ($status == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
        $this->_getResource()->updateProduct($productId, $store);
        $this->_getResource()->updateChildrenDataFromParent($store, $productId);
    }
    else { //IF the product is disabled it is removed from the flat tables
        $this->_getResource()->removeProduct($productId, $store);
    }

    return $this;
}

Still if you want to get disabled product collection then you can get only from EAV tables

For that

$collection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED));

It will return only disabled product collection

And if you want to both product collection then you have disabled FLAT catalog

| improve this answer | |
0

In magento, disabled products are not indexed in the flat table. so you can get disabled products using only EAV tables. You can disable FLAT tables in system configuration by setting System->Config->Catalog and Frontend -> Use Flat Catalog Product as NO

After this, you can get the disabled products by

 $collection = Mage::getResourceModel('catalog/product_collection')
 ->addAttributeToFilter('type_id', array('eq' => 'configurable'))
 ->addAttributeToSelect('*')
 ->addAttributeToFilter('status', array('eq' =>
       Mage_Catalog_Model_Product_Status::STATUS_DISABLED)); 

To select only few attributes like name, price change the ->addAttributeToSelect('*') to ->addAttributeToSelect('name')->addAttributeToSelect('price')

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.