/** * 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)); } }
/** * Initializes the criteria object with conditions based on the given parameter. * * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object * @param \stdClass $params Object that may contain the properties "condition", "sort", "dir", "start" and "limit" */ private function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $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)); } }
/** * 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; }
/** * Initializes the criteria object with conditions based on the given parameter * * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object * @param array $params List of criteria data with condition, sorting and paging */ private function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) { if (isset($params['filter']) && isset($params['filter']['key'])) { $expr = array(); $existing = $criteria->getConditions(); foreach ((array) $params['filter']['key'] as $idx => $key) { if ($key != '' && isset($params['filter']['op'][$idx]) && $params['filter']['op'][$idx] != '' && isset($params['filter']['val'][$idx])) { $expr[] = $criteria->compare($params['filter']['op'][$idx], $key, $params['filter']['val'][$idx]); } } $expr[] = $existing; $criteria->setConditions($criteria->combine('&&', $expr)); } }
/** * Initializes the criteria object with conditions based on the given parameter * * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object * @param array $params List of criteria data with condition, sorting and paging */ protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) { if (!isset($params['filter'])) { return; } $existing = $criteria->getConditions(); $criteria->setConditions($criteria->toConditions((array) $params['filter'])); $expr = array($criteria->getConditions(), $existing); $criteria->setConditions($criteria->combine('&&', $expr)); }
/** * Adds the conditions for searching the catalog nodes * * @param \Aimeos\MW\Criteria\Iface $search Search object * @return \Aimeos\MW\Criteria\Iface Enhanced search object */ protected function addSearchConditions(\Aimeos\MW\Criteria\Iface $search, array $catIds, $catId) { $config = $this->getContext()->getConfig(); $expr = $search->compare('==', 'catalog.parentid', $catIds); $expr = $search->combine('||', array($expr, $search->compare('==', 'catalog.id', $catId))); /** client/html/catalog/filter/tree/levels-always * The number of levels in the category tree that should be always displayed * * Usually, only the root node and the first level of the category * tree is shown in the frontend. Only if the user clicks on a * node in the first level, the page reloads and the sub-nodes of * the chosen category are rendered as well. * * Using this configuration option you can enforce the given number * of levels to be always displayed. The root node uses level 0, the * categories below level 1 and so on. * * In most cases you can set this value via the administration interface * of the shop application. In that case you often can configure the * levels individually for each catalog filter. * * @param integer Number of tree levels * @since 2014.03 * @category User * @category Developer * @see client/html/catalog/filter/tree/startid * @see client/html/catalog/filter/tree/levels-only * @see client/html/catalog/filter/tree/domains */ if (($levels = $config->get('client/html/catalog/filter/tree/levels-always')) != null) { $expr = $search->combine('||', array($expr, $search->compare('<=', 'catalog.level', $levels))); } /** client/html/catalog/filter/tree/levels-only * No more than this number of levels in the category tree should be displayed * * If the user clicks on a category node, the page reloads and the * sub-nodes of the chosen category are rendered as well. * Using this configuration option you can enforce that no more than * the given number of levels will be displayed at all. The root * node uses level 0, the categories below level 1 and so on. * * In most cases you can set this value via the administration interface * of the shop application. In that case you often can configure the * levels individually for each catalog filter. * * @param integer Number of tree levels * @since 2014.03 * @category User * @category Developer * @see client/html/catalog/filter/tree/startid * @see client/html/catalog/filter/tree/levels-always * @see client/html/catalog/filter/tree/domains */ if (($levels = $config->get('client/html/catalog/filter/tree/levels-only')) != null) { $expr = $search->combine('&&', array($expr, $search->compare('<=', 'catalog.level', $levels))); } $search->setConditions($expr); return $search; }
/** * Initializes the criteria object with conditions based on the given parameter * * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object * @param array $params List of criteria data with condition, sorting and paging */ private function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) { if (isset($params['filter']) && is_array($params['filter'])) { $existing = $criteria->getConditions(); $criteria->setConditions($criteria->toConditions((array) $params['filter'])); $expr = array($criteria->getConditions(), $existing); $criteria->setConditions($criteria->combine('&&', $expr)); } }