문제

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