Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. /**
  2. * Retireve count of collection loaded items
  3. *
  4. * @return int
  5. */
  6. public function count()
  7. {
  8. $this->load();
  9. return count($this->_items);
  10. }
  11.  
  12. /**
  13. * Get collection size
  14. *
  15. * @return int
  16. */
  17. public function getSize()
  18. {
  19. if (is_null($this->_totalRecords)) {
  20. $sql = $this->getSelectCountSql();
  21. $this->_totalRecords = $this->getConnection()->fetchOne($sql, $this->_bindParams);
  22. }
  23. return intval($this->_totalRecords);
  24. }
  25.  
  26. $collection = Mage::getModel('zzz/zzz')->getCollection();
  27. var_dump($collection->getSize());
  28.  
  29. if (!$datas->getData() || empty($datas->getData())) {
  30. // do things
  31. }
  32.  
  33. $collection = Mage::getModel('zzz/zzz')->getCollection();
  34. var_dump($collection->count());
  35.  
  36. <?php
  37. if(isset($pro_collection) && count($pro_collection) > 0) {
  38. /* Your code here */
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement