Exemple #1
0
 /**
  * Adds the conditions for the selected attributes to the given search filter.
  *
  * @param array $params Associative list of parameters that should be used for filtering
  * @param MW_Common_Criteria_Interface $filter Criteria object for searching
  */
 protected function _addAttributeFilterByParam(array $params, MW_Common_Criteria_Interface $filter)
 {
     $attrids = isset($params['f_attrid']) ? (array) $params['f_attrid'] : array();
     if (!empty($attrids)) {
         $func = $filter->createFunction('catalog.index.attributeaggregate', array(array_keys($attrids)));
         $expr = array($filter->getConditions(), $filter->compare('==', $func, count($attrids)));
         $filter->setConditions($filter->combine('&&', $expr));
     }
 }
Exemple #2
0
 /**
  * Returns the site coditions for the search request
  *
  * @param MW_Common_Criteria_Interface $search Search criteria
  * @param string[] Sorted list of criteria keys
  * @param array Associative list of search keys and objects implementing the MW_Common_Criteria_Attribute_Interface
  * @param string[] $siteIds List of site IDs that should be used for searching
  * @return array List of search conditions implementing MW_Common_Criteria_Expression_Interface
  * @since 2015.01
  */
 protected function _getSearchSiteConditions(MW_Common_Criteria_Interface $search, array $keys, array $attributes, array $siteIds)
 {
     $cond = array();
     $sep = $this->_getKeySeparator();
     foreach ($keys as $key) {
         $name = $key . $sep . 'siteid';
         if (isset($attributes[$name])) {
             $cond[] = $search->compare('==', $name, $siteIds);
         }
     }
     return $cond;
 }
Exemple #3
0
 /**
  * Returns the given search filter with the conditions attached for filtering texts.
  *
  * @param MW_Common_Criteria_Interface $search Criteria object used for product search
  * @param string $input Search string entered by the user
  * @param string $listtype List type of the text associated to the product, usually "default"
  * @return MW_Common_Criteria_Interface Criteria object containing the conditions for searching
  */
 public function addProductFilterText(MW_Common_Criteria_Interface $search, $input, $listtype = 'default')
 {
     $langid = $this->_getContext()->getLocale()->getLanguageId();
     $expr = array($search->compare('>', $search->createFunction('catalog.index.text.relevance', array($listtype, $langid, $input)), 0));
     $expr[] = $search->getConditions();
     $search->setConditions($search->combine('&&', $expr));
     return $search;
 }