/** * Retrieve clean select with joined index table * * Joined table has index * * @param Mage_Catalog_Model_Layer_Filter_Decimal $filter * @return Varien_Db_Select */ protected function _getSelect($filter) { $_select = $filter->getLayer()->getSelectWithoutFilter($filter->getRequestVar()); if ($_select) { $select = clone $_select; } else { $collection = $filter->getLayer()->getProductCollection(); $select = clone $collection->getSelect(); } // reset columns, order and limitation conditions $select->reset(Zend_Db_Select::COLUMNS); $select->reset(Zend_Db_Select::ORDER); $select->reset(Zend_Db_Select::LIMIT_COUNT); $select->reset(Zend_Db_Select::LIMIT_OFFSET); $select->reset(Zend_Db_Select::GROUP); $attributeId = $filter->getAttributeModel()->getId(); $storeId = Mage::app()->getStore()->getId(); $select->join(array('decimal_index' => $this->getMainTable()), "e.entity_id=decimal_index.entity_id AND decimal_index.attribute_id={$attributeId}" . " AND decimal_index.store_id={$storeId}", array()); return $select; }
/** * Retrieve clean select with joined index table * * Joined table has index * * @param Mage_Catalog_Model_Layer_Filter_Decimal $filter * @return Varien_Db_Select */ protected function _getSelect($filter) { $base_select = $filter->getLayer()->getBaseSelect(); if (isset($base_select[$filter->getRequestVar()])) { $select = $base_select[$filter->getRequestVar()]; } else { $collection = $filter->getLayer()->getProductCollection(); $select = clone $collection->getSelect(); } // reset columns, order and limitation conditions $select->reset(Zend_Db_Select::COLUMNS); $select->reset(Zend_Db_Select::ORDER); $select->reset(Zend_Db_Select::LIMIT_COUNT); $select->reset(Zend_Db_Select::LIMIT_OFFSET); $select->reset(Zend_Db_Select::GROUP); $select->reset(Zend_Db_Select::WHERE); $attributeId = $filter->getAttributeModel()->getId(); $storeId = Mage::app()->getStore()->getId(); $select->join(array('decimal_index' => $this->getMainTable()), "e.entity_id=decimal_index.entity_id AND decimal_index.attribute_id={$attributeId}" . " AND decimal_index.store_id={$storeId}", array()); $_collection = clone $filter->getLayer()->getProductCollection(); $searched_entity_ids = $_collection->load()->getSearchedEntityIds(); if ($searched_entity_ids && is_array($searched_entity_ids) && count($searched_entity_ids)) { $select->where('e.entity_id IN (?)', $searched_entity_ids); } return $select; }