<?php include_once realpath(dirname(__FILE__)) . '/../advancedsearch/AdvSearch.php'; error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE); ini_set('display_errors', 1); /***** Get requested variables *****/ $search = $_POST['search']; $search = array('A', 'G', 'X', 'K'); $variable = $_POST['variable']; $select = $_POST['select']; $condition = $_POST['condition']; $avdSearch = new AdvSearch(); $avdSearch->setSearchKeywords($search); $avdSearch->setWhereVariable($variable); $avdSearch->setWhereRule($select); $avdSearch->setWhereCondition($condition); echo json_encode($avdSearch->doSearch());
public static function queryCategories($cats) { $categs = ''; if (!is_array($cats)) { $cats = urldecode($cats); $pos = strpos($cats, ','); if ($pos !== false) { $cats = explode(",", $cats); } else { $cats = array($cats); } } if ($cats[0] > 0) { foreach ($cats as $key => $val) { $categs .= $val . ','; $categs .= AdvSearch::categoriesLower($val); } } $displaycats = explode(",", $categs); array_pop($displaycats); $displaycategories = 'INNER JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (p.id_product = cp.id_product '; if (count($displaycats) && $displaycats[0] > 0) { $i = 0; $ile = count($displaycats); foreach ($displaycats as $key => $val) { if ($ile - 1 == $i && $i != 0) { $displaycategories .= ' || id_category =' . intval($val) . ') '; } elseif ($ile - 1 == $i && $i == 0) { $displaycategories .= ' AND id_category=' . intval($val) . ' '; } else { if ($ile > 0 && $i == 0) { $displaycategories .= ' AND ( id_category =' . intval($val) . ' '; } else { $displaycategories .= ' || id_category =' . intval($val) . ' '; } } $i++; } } $displaycategories .= ')'; return $displaycategories; }
$p = abs(intval(Tools::getValue('p', 1))); $search = AdvSearch::find_adv(intval($cookie->id_lang), Tools::getValue('search_queryy'), $p, $n, $orderBy, $orderWay); $nbProducts = $search['total']; include dirname(__FILE__) . '/../../pagination.php'; /*$smarty->assign(array( 'products' => $search->find_adv(intval($cookie->id_lang),Tools::getValue('search_queryy'), $p, $n, $orderBy,$orderWay), 'nbProducts' => $nbProducts, 'advSearch' => 'Advanced Search')); */ $smarty->assign(array('products' => $search['result'], 'nbProducts' => $search['total'], 'query' => 'Advanced Search')); } } else { if ($query = Tools::getValue('search_query', Tools::getValue('tag', Tools::getValue('ref'))) and !is_array($query)) { $n = abs(intval(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')))); $p = abs(intval(Tools::getValue('p', 1))); $search = AdvSearch::find(intval($cookie->id_lang), $query, $p, $n, $orderBy, $orderWay); $nbProducts = $search['total']; include dirname(__FILE__) . '/../../pagination.php'; $smarty->assign(array('products' => $search['result'], 'nbProducts' => $search['total'], 'query' => $query)); } else { $smarty->assign(array('products' => array(), 'pages_nb' => 1, 'nbProducts' => 0)); } } function HOOK_PRODUCT_LIST_ACTIONS($params) { global $product; $product = $params['product']; return Module::hookExec('productListActions'); } if (!isset($_GET['id_category'])) { $_GET['id_category'] = 0;