I recently found the following article regarding the use of the Magento resource modeler when invoking large product collections, to save resources - http://www.fontis.com.au/blog/magento/loading-large-collections . However, it’s hard for me to figure out how to get it to output the same data.
So, suppose I use the following to get a complete collection of products and display sku's:
$productCollection = Mage::getModel('catalog/product')->getCollection();
foreach($productCollection as $product){
echo $product->getSku().',';
}
Using the profiler, I see that it uses 1,154,480 bytes for processing.
Now, using the resource iterator model, do the following:
function productCallback($args)
{
$product = Mage::getModel('catalog/product');
$product->setData($args['row']);
echo $product->getSku().',';
}
$_productCollection = Mage::getModel('catalog/product')->getCollection();;
$_productCollection = Mage::getSingleton('core/resource_iterator')->walk($_productCollection->getSelect(), array('productCallback'));
In this case, 199,912 bytes are used. So much the difference to get the same, is simply sku's basic list.
, , , , URL- .., foreach $productCollection, :
foreach($_productCollection as $product){
echo $product->getSku().',';
};
. , , , foreach, .
, , , foreach? ? , ?