سؤال

How can I get a catalog/product collection with all attributes which are selected to be "used in product listing", i.e. are in the flat table?

هل كانت مفيدة؟

المحلول

$collection
    ->addAttributeToSelect(
          Mage::getSingleton('catalog/config')->getProductAttributes()
    );

This is for example used in Mage_Catalog_Model_Layer::prepareProductCollection.

نصائح أخرى

Looks like

Mage::getSingleton('catalog/config')->getProductAttributes()

doesn't include all flat attributes. Still missing some attributes. Use the flat reindexer Model instead to get exactly attributes that are in Flat table:

Mage::getModel('catalog/resource_product_flat_indexer')->getAttributeCodes();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top