---
title: "Use call back function to proccess Magento large collection"
author: "cgzhang"
date: "2011-01-19T12:58:16Z"
tags: ["PHP"]
categories: ["编程语言"]
slug: "use-call-back-function-to-proccess-magento-large-collection"
draft: false
lastmod: "2011-01-19T12:58:16Z"
id: 888587
url: "https://magentosh.iteye.com/blog/888587"
---

\[code="php"] $orders = Mage::getModel('sales/order')-&gt;getCollection(); Mage::getSingleton('core/resource\_iterator')-&gt;walk($orders-&gt;getSelect(), array(array($this,'proccessOrder'))); public function proccessOrder($args) { $order = Mage::getModel('sales/order'); $order-&gt;setData($args\['row']); echo $order-&gt;getIncrementId() . '  
'; echo $order-&gt;getGrandTotal() . '  
'; $orderAmount = $orderAmount+$order-&gt;getGrandTotal(); echo '----------------------  
'; } \[/code]