Last active
February 20, 2019 14:20
-
-
Save antiseptikk/ed988c46938e3846e00621c8d5f55440 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$collection = Mage::getModel('catalog/product') | |
->getCollection() | |
->addAttributeToFilter('col', array('eq' => $value)); | |
// Add a page size to the result set. | |
$collection->setPageSize(25); | |
$pages = $collection->getLastPageNumber(); | |
$currentPage = 1; | |
do { | |
// Tell the collection which page to load. | |
$collection->setCurPage($currentPage); | |
$collection->load(); | |
foreach ($collection as $item) { | |
// do stuff | |
// tip to save memory | |
// $_child = Mage::getModel('catalog/product')->load($child->getId()); | |
// $_child->clearInstance(); | |
} | |
// make the collection unload the data in memory so it will pick up the next page when load() is called. | |
$collection->clear(); | |
$currentPage++; | |
} while ($currentPage <= $pages); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment