1) { if ('page' == $alias[$aliasCount - 2] && is_numeric($alias[$aliasCount - 1])) { $alias = array_slice($alias, 0, -2); } } $db = Qs_Db::getInstance(); $tableShortName = 'ProductCategory'; $alias = array_reverse($alias); $iteration = 0; $select = $db->select(); $select->from(array('i' . $iteration => Qs_Db::getTableName($tableShortName)), 'id'); $select->where('`i' . $iteration . '`.`alias` = ?', (string) array_shift($alias)); while (!empty($alias)) { $iteration++; $select->join( array('i' . $iteration => Qs_Db::getTableName($tableShortName)), '`i' . $iteration . '`.`id` = `i' . ($iteration - 1) . '`.`parentId`', '' ); $select->where('`i' . $iteration . '`.`alias` = ?', (string) array_shift($alias)); } return $db->fetchOne($select); } protected function _getProductsCountSubselect() { $select = parent::_getProductsCountSubselect(); $select->join($this->_getPair('Product'), '`Product`.`id` = `Product2Category`.`productId`', ''); $select->where('`Product`.`enabled` = "y"'); return $select; } public function setCategoryIdByAlias($alias) { $categoryId = static::getCategoryIdByAlias($alias); $this->setCategoryId($categoryId); return $this; } public function setCategoryId($categoryId) { $this->_categoryId = $categoryId; return $this; } public function getCategoryId() { return $this->_categoryId; } public function getListSelect() { if (null === $this->_select) { parent::getListSelect(); $this->_select->where('`' . $this->_tableAlias . '`.`enabled` = "y"'); } return $this->_select; } }