From 4e7a8e134ab62f5b5532bec50890e3abf3809b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Dav=C3=ADdek?= Date: Thu, 23 Dec 2021 13:22:11 +0100 Subject: [PATCH] Revert of Mage_Adminhtml_Block_Widget_Grid::_exportIterateCollection (#1914) --- .../core/Mage/Adminhtml/Block/Widget/Grid.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index db28a0024b4..e34f0229e3a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -971,23 +971,29 @@ public function _exportIterateCollection($callback, array $args) $originalCollection = $this->getCollection(); $count = null; $page = 1; + $lPage = null; + $break = false; - do { + while ($break !== true) { $collection = clone $originalCollection; $collection->setPageSize($this->_exportPageSize); $collection->setCurPage($page); $collection->load(); - - $count = $collection->count(); - - $page++; + if (is_null($count)) { + $count = $collection->getSize(); + $lPage = $collection->getLastPageNumber(); + } + if ($lPage == $page) { + $break = true; + } + $page ++; foreach ($collection as $item) { call_user_func_array(array($this, $callback), array_merge(array($item), $args)); } $collection->clear(); unset($collection); - } while($count == $this->_exportPageSize); + } } /**