keywords2categories / api / autocomplete / autocomplete.php @ 3
Historie | Anzeigen | Annotieren | Download (5,4 KB)
1 |
<?php
|
---|---|
2 |
/* -----------------------------------------------------------------------------------------
|
3 |
$Id: autocomplete.php 13450 2021-03-05 16:29:46Z GTB $
|
4 |
|
5 |
modified eCommerce Shopsoftware
|
6 |
http://www.modified-shop.org
|
7 |
|
8 |
Copyright (c) 2009 - 2013 [www.modified-shop.org]
|
9 |
-----------------------------------------------------------------------------------------
|
10 |
Released under the GNU General Public License
|
11 |
---------------------------------------------------------------------------------------*/
|
12 |
|
13 |
chdir('../../'); |
14 |
include('includes/application_top.php'); |
15 |
|
16 |
|
17 |
// include needed functions
|
18 |
require_once (DIR_FS_INC.'xtc_parse_search_string.inc.php'); |
19 |
|
20 |
$module_smarty = new Smarty; |
21 |
$module_smarty->assign('language', $_SESSION['language']); |
22 |
|
23 |
if (isset($_POST['queryString'])) { |
24 |
$from_str = $where_str = ''; |
25 |
|
26 |
$queryString = stripslashes(trim(decode_utf8(urldecode($_POST['queryString'])))); |
27 |
$categories_id = !empty($_POST['categories_id']) ? (int)$_POST['categories_id'] : false; |
28 |
$inc_subcat = !empty($_POST['inc_subcat']) ? (int)$_POST['inc_subcat'] : null; |
29 |
|
30 |
// create $search_keywords array
|
31 |
$keywordcheck = xtc_parse_search_string($queryString, $search_keywords); |
32 |
|
33 |
if ($keywordcheck === true && mb_strlen($queryString, $_SESSION['language_charset']) >= SEARCH_AC_MIN_LENGTH) { |
34 |
|
35 |
$from_str .= SEARCH_IN_ATTR == 'true' ? " LEFT OUTER JOIN ".TABLE_PRODUCTS_ATTRIBUTES." AS pa ON (p.products_id = pa.products_id) |
36 |
LEFT OUTER JOIN ".TABLE_PRODUCTS_OPTIONS_VALUES." AS pov ON (pa.options_values_id = pov.products_options_values_id) " : ""; |
37 |
$from_str .= SEARCH_IN_MANU == 'true' ? " LEFT OUTER JOIN ".TABLE_MANUFACTURERS." AS m ON (p.manufacturers_id = m.manufacturers_id) " : ""; |
38 |
|
39 |
if (SEARCH_IN_FILTER == 'true') { |
40 |
$from_str .= "LEFT JOIN ".TABLE_PRODUCTS_TAGS." pt ON (pt.products_id = p.products_id) |
41 |
LEFT JOIN ".TABLE_PRODUCTS_TAGS_VALUES." ptv ON (ptv.options_id = pt.options_id AND ptv.values_id = pt.values_id AND ptv.status = '1' AND ptv.languages_id = '".(int)$_SESSION['languages_id']."') "; |
42 |
} |
43 |
|
44 |
//include subcategories if needed
|
45 |
if ($categories_id !== false) { |
46 |
if ($inc_subcat == '1') { |
47 |
$subcategories_array = array(); |
48 |
xtc_get_subcategories($subcategories_array, $categories_id); |
49 |
$from_str .= " LEFT OUTER JOIN ".TABLE_PRODUCTS_TO_CATEGORIES." AS p2c ON (p.products_id = p2c.products_id) "; |
50 |
$where_str .= " AND p2c.categories_id IN ('".$categories_id."' "; |
51 |
foreach ($subcategories_array AS $scat) { |
52 |
$where_str .= ", '".$scat."'"; |
53 |
} |
54 |
$where_str .= ") "; |
55 |
} else {
|
56 |
$from_str .= " LEFT OUTER JOIN ".TABLE_PRODUCTS_TO_CATEGORIES." AS p2c ON (p.products_id = p2c.products_id) "; |
57 |
$where_str .= " AND p2c.categories_id = '".$categories_id."' "; |
58 |
} |
59 |
} |
60 |
|
61 |
include(DIR_WS_INCLUDES.'build_search_query.php'); |
62 |
|
63 |
$where_str .= " ) "; |
64 |
|
65 |
$autocomplete_search_query = "SELECT ".$product->default_select." |
66 |
FROM ".TABLE_PRODUCTS." p |
67 |
JOIN ".TABLE_PRODUCTS_DESCRIPTION." pd |
68 |
ON p.products_id = pd.products_id
|
69 |
AND pd.language_id = '".(int)$_SESSION['languages_id']."' |
70 |
AND trim(pd.products_name) != ''
|
71 |
".$from_str." |
72 |
WHERE p.products_status = '1'
|
73 |
".$where_str." |
74 |
".PRODUCTS_CONDITIONS_P." |
75 |
GROUP BY p.products_id
|
76 |
ORDER BY p.products_id ASC
|
77 |
LIMIT ".MAX_DISPLAY_ADVANCED_SEARCH_RESULTS; |
78 |
|
79 |
# Modul Kategorie-Keywords: Erg?nzung relevanter Artikel IDs
|
80 |
if(defined('MODULE_CATEGORY_KEYWORDS_STATUS') |
81 |
&& MODULE_CATEGORY_KEYWORDS_STATUS == 'True'){ |
82 |
require_once (DIR_WS_INCLUDES.'extra/default/listing_sql/category_keywords.php'); |
83 |
# Erg?nzung relevanter Artikel IDs
|
84 |
if(isset($arr_included_products)){ |
85 |
$autocomplete_search_query = str_replace("AND ( (", "AND ( ( p.products_id IN (".join($arr_included_products, ",") . ") OR ", $autocomplete_search_query); |
86 |
} |
87 |
# Erg?nzung relevanter Kategorien
|
88 |
if(count($categories_keyword_content) > 0) { |
89 |
$module_smarty->assign('categories_content', $categories_keyword_content); |
90 |
} |
91 |
} |
92 |
$autocomplete_search_query = xtc_db_query($autocomplete_search_query); |
93 |
if (xtc_db_num_rows($autocomplete_search_query) > 0) { |
94 |
$module_content = array(); |
95 |
while ($autocomplete_search = xtc_db_fetch_array($autocomplete_search_query)) { |
96 |
$module_content[] = $product->buildDataArray($autocomplete_search); |
97 |
} |
98 |
$module_smarty->assign('module_content', $module_content); |
99 |
} else {
|
100 |
$module_smarty->assign('error', 'true'); |
101 |
} |
102 |
$module_smarty->caching = 0; |
103 |
$module_smarty->display(CURRENT_TEMPLATE.'/module/autocomplete.html'); |
104 |
} |
105 |
} |
106 |
?>
|