Skip to content

Commit f06d2bf

Browse files
authored
_exportIterateCollection performance optimization (OpenMage#1467)
* _exportIterateCollection performance optimization * Update _exportIterateCollection
1 parent ce3171d commit f06d2bf

File tree

1 file changed

+6
-13
lines changed
  • app/code/core/Mage/Adminhtml/Block/Widget

1 file changed

+6
-13
lines changed

app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -963,36 +963,29 @@ protected function _getExportTotals()
963963
*
964964
* @param string $callback
965965
* @param array $args additional arguments for callback method
966-
* @return $this
967966
*/
968967
public function _exportIterateCollection($callback, array $args)
969968
{
970969
$originalCollection = $this->getCollection();
971970
$count = null;
972971
$page = 1;
973-
$lPage = null;
974-
$break = false;
975972

976-
while ($break !== true) {
973+
do {
977974
$collection = clone $originalCollection;
978975
$collection->setPageSize($this->_exportPageSize);
979976
$collection->setCurPage($page);
980977
$collection->load();
981-
if (is_null($count)) {
982-
$count = $collection->getSize();
983-
$lPage = $collection->getLastPageNumber();
984-
}
985-
if ($lPage == $page) {
986-
$break = true;
987-
}
988-
$page ++;
978+
979+
$count = $collection->count();
980+
981+
$page++;
989982

990983
foreach ($collection as $item) {
991984
call_user_func_array(array($this, $callback), array_merge(array($item), $args));
992985
}
993986
$collection->clear();
994987
unset($collection);
995-
}
988+
} while($count == $this->_exportPageSize);
996989
}
997990

998991
/**

0 commit comments

Comments
 (0)