Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. So sometimes $userID seems to be empty or something and I get memory usage to the point where the process dies.
  2. <?php
  3. $result = Mage::getModel('customer/customer')
  4. ->getCollection()
  5. ->addAttributeToSelect('alternative_id')
  6. ->addAttributeToFilter('alternative_id', $userID)
  7. ->load();
  8.  
  9. if ($result->getSize() === 1) {
  10. return $result->getFirstItem();
  11. } else {
  12. return false;
  13. }
  14.  
  15.  
  16. Does this look better?
  17. <?php
  18. $result = Mage::getModel('customer/customer')
  19. ->getCollection()
  20. ->addAttributeToSelect('alternative_id')
  21. ->addAttributeToFilter('alternative_id', $userID)
  22. ->setPageSize(3) //added this
  23. ->setCurPage(1) //added this
  24. ->load();
  25.  
  26. if ($result->getSize() === 1) {
  27. return $result->getFirstItem();
  28. } else {
  29. return false;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement