On product list/grid magento already has collection of products, and get from it products using foreach.

$_productCollection=$this->getLoadedProductCollection();
...
foreach ($_productCollection as $_product):

But these products don't have all necessary properties. I'm not sure, but i thing they have no inventory data. But i need some elements of _data array. I know only one way how to do that:

$_product = Mage::getModel('catalog/product')->load($_product->getId());

Is there any another way, how to reload product properties?

有帮助吗?

解决方案

If you need some data in the product list, edit the attribute in the backend and set the field "Used in product listing" to Yes.
Save it and rebuild your indexes.

There is also the option of loading the product inside the foreach loop but this can lead to performance issues.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top