/** * 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)); } }
/** * 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; }
/** * Initializes the criteria object with conditions based on the given parameter. * * @param MW_Common_Criteria_Interface $criteria Criteria object * @param stdClass $params Object that may contain the properties "condition", "sort", "dir", "start" and "limit" */ private function _initCriteriaConditions(MW_Common_Criteria_Interface $criteria, stdClass $params) { if (isset($params->condition) && is_object($params->condition)) { $existing = $criteria->getConditions(); $criteria->setConditions($criteria->toConditions((array) $params->condition)); $expr = array($criteria->getConditions(), $existing); $criteria->setConditions($criteria->combine('&&', $expr)); } }