I want to loop over an array of product IDs in Magento. In the loop I am displaying some custom attributes of the products as:
foreach ($products as $product
You´ll find the difference between getModel() and getSingleton() in the other answers.
But if you want to speed up your code, assuming you have a collection, do the following:
$products->addAttributeToSelect('credits');
foreach ($products as $product) {
echo '
' . $product->getCredits();
}
So you don´t have to load every product, which is very time-consuming.