Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <?php
  2.  
  3. $collection = Mage::getModel('catalog/product')
  4. ->getCollection()
  5. ->addAttributeToFilter('col', array('eq' => $value));
  6.  
  7. // Add a page size to the result set.
  8. $collection->setPageSize(25);
  9. $pages = $collection->getLastPageNumber();
  10. $currentPage = 1;
  11.  
  12. do {
  13. // Tell the collection which page to load.
  14. $collection->setCurPage($currentPage);
  15. $collection->load();
  16.  
  17. foreach ($collection as $item) {
  18. // do stuff
  19.  
  20. // tip to save memory
  21. // $_child = Mage::getModel('catalog/product')->load($child->getId());
  22. // $_child->clearInstance();
  23. }
  24.  
  25.  
  26. // make the collection unload the data in memory so it will pick up the next page when load() is called.
  27. $collection->clear();
  28. $currentPage++;
  29.  
  30. } while ($currentPage <= $pages);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement