Exemple #1
0
 public function loadByQuery($object, $text)
 {
     $oQuery = new Solarium_Query_Select_FilterQuery();
     $oQuery->setKey('fq_show_products')->addTag('showProducts')->setQuery($text);
     $this->_results = $this->_getSolrReadAdapter()->getDocuments('catalog/product', array($oQuery), true);
     if (is_array($this->_results) && count($this->_results) > 0) {
         $aData = array();
         foreach (current($this->_results) as $oResult) {
             $aData[] = $oResult->getData();
         }
         $object->addData($aData);
     }
     return $this;
 }
 /**
  * Create a filterquery instance
  *
  * If you supply a string as the first arguments ($options) it will be used as the key for the filterquery
  * and it will be added to this query.
  * If you supply an options array/object that contains a key the filterquery will also be added to the query.
  *
  * When no key is supplied the filterquery cannot be added, in that case you will need to add it manually
  * after setting the key, by using the addFilterQuery method.
  *
  * @param mixed $options
  * @return Solarium_Query_Select_FilterQuery
  */
 public function createFilterQuery($options = null)
 {
     if (is_string($options)) {
         $fq = new Solarium_Query_Select_FilterQuery();
         $fq->setKey($options);
     } else {
         $fq = new Solarium_Query_Select_FilterQuery($options);
     }
     if ($fq->getKey() !== null) {
         $this->addFilterQuery($fq);
     }
     return $fq;
 }
 public function testSetFilterQueries()
 {
     $fq1 = new Solarium_Query_Select_FilterQuery();
     $fq1->setKey('fq1')->setQuery('category:1');
     $fq2 = new Solarium_Query_Select_FilterQuery();
     $fq2->setKey('fq2')->setQuery('category:2');
     $filterQueries1 = array('fq1' => $fq1, 'fq2' => $fq2);
     $this->_query->addFilterQueries($filterQueries1);
     $fq3 = new Solarium_Query_Select_FilterQuery();
     $fq3->setKey('fq3')->setQuery('category:3');
     $fq4 = new Solarium_Query_Select_FilterQuery();
     $fq4->setKey('fq4')->setQuery('category:4');
     $filterQueries2 = array('fq3' => $fq3, 'fq4' => $fq4);
     $this->_query->setFilterQueries($filterQueries2);
     $this->assertEquals($filterQueries2, $this->_query->getFilterQueries());
 }