/**
  * @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)));
 }
Example #2
0
 /**
  * @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)));
 }
Example #3
0
 /**
  * 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)));
 }
Example #5
0
 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;
 }
Example #7
0
 /**
  * @param Enterprise_Search_Model_Resource_Collection $collection
  */
 public function applyToCollection($collection)
 {
     $collection->addFqFilter(array($this->_getFilterField() => array('or' => $this->getMSelectedValues())));
 }
Example #8
0
 /**
  * @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)));
 }
Example #9
0
 /**
  * @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())));
 }
Example #10
0
 /**
  * @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())));
 }
Example #11
0
 /**
  * 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;
 }