/** * 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 \Aimeos\MW\Criteria\Iface $filter Criteria object for searching */ protected function addAttributeFilterByParam(array $params, \Aimeos\MW\Criteria\Iface $filter) { $attrids = isset($params['f_attrid']) ? (array) $params['f_attrid'] : array(); if (!empty($attrids)) { $func = $filter->createFunction('index.attributeaggregate', array(array_keys($attrids))); $expr = array($filter->getConditions(), $filter->compare('==', $func, count($attrids))); $filter->setConditions($filter->combine('&&', $expr)); } }
/** * 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 \Aimeos\MW\Criteria\Iface $filter Criteria object for searching */ protected function addAttributeFilterByParam(array $params, \Aimeos\MW\Criteria\Iface $filter) { $attrids = array(); if (isset($params['f_attrid'])) { foreach ((array) $params['f_attrid'] as $attrid) { if ($attrid != '') { $attrids[] = (int) $attrid; } } } if (!empty($attrids)) { $func = $filter->createFunction('index.attributeaggregate', array($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 by text. * * @param \Aimeos\MW\Criteria\Iface $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 \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching * @since 2015.08 */ public function addIndexFilterText(\Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default') { $langid = $this->getContext()->getLocale()->getLanguageId(); $expr = array($search->compare('>', $search->createFunction('index.text.relevance', array($listtype, $langid, $input)), 0)); $expr[] = $search->getConditions(); $search->setConditions($search->combine('&&', $expr)); return $search; }