
Untitled
By: a guest on
May 16th, 2012 | syntax:
None | size: 1.02 KB | hits: 15 | expires: Never
Magento - fetching products and looping through is getting slower and slower
$product = Mage::getModel('catalog/product');
$data = $product->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('type_id', 'simple');
$num_products = $product->getCollection()->count();
echo 'exporting '.$num_products."n";
print "starting exportn";
$start_time = time();
foreach ($data as $tProduct) {
// doing some stuff, no sql !
}
VIRT RES SHR S CPU% MEM%
680M 504M 8832 R 90.0 6.3
public function __construct(Zend_Db_Adapter_Abstract $adapter)
{
parent::__construct($adapter);
if (!in_array(self::STRAIGHT_JOIN_ON, self::$_joinTypes)) {
self::$_joinTypes[] = self::STRAIGHT_JOIN_ON;
self::$_partsInit = array(self::STRAIGHT_JOIN => false) + self::$_partsInit;
}
}
public function __construct(Zend_Db_Adapter_Abstract $adapter)
{
parent::__construct($adapter);
self::$_joinTypes[] = self::STRAIGHT_JOIN_ON;
self::$_partsInit = array(self::STRAIGHT_JOIN => false) + self::$_partsInit;
}