1

in frontend/rwd/default/template/catalog/product/list.phtml round line 48 the $_product is fetched from the collection.

Our products have a style attribute. But that is missing here.

var_dump(get_class($_product)); // Mage_Catalog_Model_Product 
var_dump( $_product->getAttributeText('style') // false

If below that I do this:

$_product = Mage::getModel('catalog/product')->load( $_product->getId() );
var_dump(get_class($_product)); // Mage_Catalog_Model_Product 
var_dump( $_product->getAttributeText('style') // get the string with the value

But (re)loading every product here for 1 attrubute is probably bad for performance. What is going on here? How can I do this better.

1 Answer 1

3

For performance reasons, not all attributes are loaded in the collection.
Only the ones marked with "Used in product listing" (and a few other system attributes).
You should edit the attribute in the backend (Catalog->Attributes->Manage attributes) and set the flag Used in product listing to Yes.
A flat catalog reindex is required after that.

Side note: be careful with how many attributes you set to be used in product listing. If they are too many, you might end up going over the sql max row limit.

1
  • Thnx that helps.
    – janw
    Jul 21, 2014 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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