/** * 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 site coditions for the search request * * @param \Aimeos\MW\Criteria\Iface $search Search criteria object * @param string[] $keys Sorted list of criteria keys * @param array $attributes Associative list of search keys and objects implementing the \Aimeos\MW\Criteria\Attribute\Iface * @param string[] $siteIds List of site IDs that should be used for searching * @return array List of search conditions implementing \Aimeos\MW\Criteria\Expression\Iface * @since 2015.01 */ protected function getSearchSiteConditions(\Aimeos\MW\Criteria\Iface $search, array $keys, array $attributes, array $siteIds) { /** mshop/common/manager/sitecheck * Enables or disables using the site IDs in search queries * * For market places, products of different shop owners managing their * own sites should be shown in the frontend. By default, only the items * from the current site are displayed. Setting this option to false * disables the restriction to the current site and shows all products * from all sites. This does also apply to all other records from * different domains than "product". * * This option is most effective if it's only set for the shop frontend, * so the shop owners will only see and manager their own products in * the administration interface. * * @param boolean True to resrict items to the current site, false to show item form all sites * @since 2016.10 * @category Developer */ if ($this->context->getConfig()->get('mshop/common/manager/sitecheck', true) == false) { return array(); } $cond = array(); $sep = $this->getKeySeparator(); foreach ($keys as $key) { $name = $key . $sep . 'siteid'; if (isset($attributes[$name])) { $cond[] = $search->compare('==', $name, $siteIds); } } return $cond; }
/** * Returns the site coditions for the search request * * @param \Aimeos\MW\Criteria\Iface $search Search criteria * @param string[] Sorted list of criteria keys * @param array Associative list of search keys and objects implementing the \Aimeos\MW\Criteria\Attribute\Iface * @param string[] $siteIds List of site IDs that should be used for searching * @return array List of search conditions implementing \Aimeos\MW\Criteria\Expression\Iface * @since 2015.01 */ protected function getSearchSiteConditions(\Aimeos\MW\Criteria\Iface $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; }
/** * 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)); } }
/** * 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; }