Created
March 27, 2014 17:36
-
-
Save ryaan-anthony/9813337 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
| /** | |
| * Get collection size | |
| * | |
| * @return int | |
| */ | |
| public function getSize() | |
| { | |
| if (is_null($this->_totalRecords)) { | |
| $sql = $this->getSelectCountSql(); | |
| $this->_totalRecords = $this->getConnection()->fetchOne($sql, $this->_bindParams); | |
| } | |
| return intval($this->_totalRecords); | |
| } | |
| /** | |
| * Get SQL for get record count | |
| * | |
| * @return Varien_Db_Select | |
| */ | |
| public function getSelectCountSql() | |
| { | |
| $this->_renderFilters(); | |
| $countSelect = clone $this->getSelect(); | |
| $countSelect->reset(Zend_Db_Select::ORDER); | |
| $countSelect->reset(Zend_Db_Select::LIMIT_COUNT); | |
| $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET); | |
| $countSelect->reset(Zend_Db_Select::COLUMNS); | |
| $countSelect->columns('COUNT(*)'); | |
| return $countSelect; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment