سؤال

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