/** * @param Enterprise_Search_Model_Resource_Collection $collection */ public function applyToCollection($collection) { $values = $this->getMSelectedValues(); $engine = Mage::getResourceSingleton('enterprise_search/engine'); if (!method_exists($engine, 'getSearchEngineFieldName')) { $labels = array(); foreach ($values as $value) { $labels[] = $this->getAttributeModel()->getFrontend()->getOption($value); } $values = $labels; } $collection->addFqFilter(array($this->getFilterField() => array('or' => $values))); }
/** * @param Enterprise_Search_Model_Resource_Collection $collection */ public function applyToCollection($collection) { $attributeCode = $this->getAttributeModel()->getAttributeCode(); $field = 'attr_decimal_' . $attributeCode; $fq = array(); foreach ($this->getMSelectedValues() as $selection) { if (strpos($selection, ',') !== false) { list($index, $range) = explode(',', $selection); $fq[] = array('from' => $range * ($index - 1), 'to' => $range * $index - ($this->isUpperBoundInclusive() ? 0 : 0.001)); } } $collection->addFqFilter(array($field => array('reverse' => $fq))); }
/** * Applies filter values provided in URL to a given product collection * * @param Enterprise_Search_Model_Resource_Collection $collection * @return void */ public function applyToCollection($collection) { $field = $this->_getFilterField(); $fq = array(); foreach ($this->getMSelectedValues() as $selection) { if (strpos($selection, ',') !== false) { list($index, $range) = explode(',', $selection); $to = $range * $index; if ($to < $this->getMaxPriceInt() && !$this->isUpperBoundInclusive()) { $to -= 0.001; } $fq[] = array('from' => $range * ($index - 1), 'to' => $to); } } $collection->addFqFilter(array($field => array('reverse' => $fq))); }
/** * Applies filter values provided in URL to a given product collection * * @param Enterprise_Search_Model_Resource_Collection $collection * @return void */ public function applyToCollection($collection) { $field = $this->_getFilterField(); $fq = array(); foreach ($this->getMSelectedValues() as $selection) { if (strpos($selection, ',') !== false) { list($index, $range) = explode(',', $selection); $range = $this->_getResource()->getPriceRange($index, $range); $range['from'] /= $this->getCurrencyRate(); $range['to'] /= $this->getCurrencyRate(); $to = $range['to']; if ($to < $this->getMaxPriceInt() / $this->getCurrencyRate() && !$this->isUpperBoundInclusive()) { $to -= 0.001; } $fq[] = array('from' => $range['from'], 'to' => $to); } } $collection->addFqFilter(array($field => array('or' => $fq))); }
public function getSize() { if (is_null($this->_totalRecords)) { if (!$this->isLoaded()) { $pageSize = $this->_pageSize; $this->_pageSize = false; $this->getSelect()->distinct(); $this->load(); $this->_pageSize = $pageSize; $this->_storedPageSize = null; } $select = clone $this->getSelect(); $select->reset(Zend_Db_Select::LIMIT_COUNT); $select->reset(Zend_Db_Select::LIMIT_OFFSET); $select->reset(Zend_Db_Select::GROUP); $connection = Mage::getSingleton('core/resource')->getConnection('read'); $result = $connection->fetchAll((string) $select); $this->_totalRecords = count($result); } return parent::getSize(); }
/** * Add filter by attribute rated price * * @param Enterprise_Search_Model_Resource_Collection $collection * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute * @param string|array $value * @param int $rate * * @return bool */ public function addRatedPriceFilter($collection, $attribute, $value, $rate = 1) { $collection->addPriceData(); $fieldName = Mage::getResourceSingleton('enterprise_search/engine')->getSearchEngineFieldName($attribute); $collection->addSearchParam(array($fieldName => $value)); return true; }
/** * @param Enterprise_Search_Model_Resource_Collection $collection */ public function applyToCollection($collection) { $collection->addFqFilter(array($this->_getFilterField() => array('or' => $this->getMSelectedValues()))); }
/** * @param Enterprise_Search_Model_Resource_Collection $collection * @param Mana_Filters_Model_Filter_Attribute $model * @param array $value * @return Mana_Filters_Resource_Solr_Attribute */ public function applyToCollection($collection, $model, $value) { $collection->addFqFilter(array($model->getFilterField() => array('and' => $value))); }
/** * @param Enterprise_Search_Model_Resource_Collection $collection */ public function applyToCollection($collection) { $engine = Mage::getResourceSingleton('enterprise_search/engine'); $facetField = $engine->getSearchEngineFieldName($this->getAttributeModel(), 'nav'); $collection->addFqFilter(array($facetField => array('and' => $this->getMSelectedValues()))); }
/** * @param Enterprise_Search_Model_Resource_Collection $collection */ public function applyToCollection($collection) { $engine = Mage::getResourceSingleton('enterprise_search/engine'); $collection->addFqFilter(array($this->getFilterField() => array('reverse' => $this->getMSelectedValues()))); }
/** * Add filter by attribute rated price * * @param Enterprise_Search_Model_Resource_Collection $collection * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute * @param string|array $value * @param int $rate * * @return bool */ public function addRatedPriceFilter($collection, $attribute, $value, $rate = 1) { $collection->addPriceData(); $collection->addSearchParam(array('price' => $value)); return true; }