/** * Get SQL for get record count * * @return Varien_Db_Select */ public function getSelectCountSql() { $countSelect = parent::getSelectCountSql(); if (Mage::app()->getRequest()->getControllerName() == 'sales_order') { $countSelect->reset(Zend_Db_Select::GROUP); $countSelect->reset(Zend_Db_Select::COLUMNS); $countSelect->columns("COUNT(DISTINCT main_table.entity_id)"); $havingCondition = $countSelect->getPart(Zend_Db_Select::HAVING); if (count($havingCondition)) { $countSelect->where(str_replace("group_concat(`sales_flat_order_item_stitching`.stitchingstatus_id SEPARATOR ', ')", 'sales_flat_order_item_stitching.stitchingstatus_id', $havingCondition[0])); $countSelect->reset(Zend_Db_Select::HAVING); } } return $countSelect; }
/** * Minimize usual count select * @return Varien_Db_Select */ public function getSelectCountSql() { $controller_name = Mage::app()->getRequest()->getControllerName(); if ($controller_name == 'sales_order' || $controller_name == 'sales_archive') { $this->_renderFilters(); $unionSelect = clone $this->getSelect(); $unionSelect->reset(Zend_Db_Select::ORDER); $unionSelect->reset(Zend_Db_Select::LIMIT_COUNT); $unionSelect->reset(Zend_Db_Select::LIMIT_OFFSET); $countSelect = clone $this->getSelect(); $countSelect->reset(); $countSelect->from(array('a' => $unionSelect), 'COUNT(*)'); } else { $countSelect = parent::getSelectCountSql(); } return $countSelect; }