I need to load one attribute value(weight) for many product IDs.
Say list of the product ids is in array $productIDs$productIDs
.
In general case, which approach is faster,
Loading raw attribute value for each product, without loading products:
foreach ($productIds as $productId) { $weight[$productId] = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'weight', $store_id ); }
Using collection:
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('id', array('in' => $productIds)); foreach ($collection as $product) { $weight[$product->getId()] = $product->getWeight(); }