Есть модуль, работающий чисто через vqmod(не помню где брал), он выводит поисковые ответы сразу после ввода.
Есть ли мастера, которые знают как добавить помимо названия и картинки добавить стоимость товара?
Вот код модуля
ставить в папку public_html/vqmod/xml у меня файл называется livesearch-02.xml
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Opencart Live Search</id>
<version>0.2</version>
<author>Kardos Sándor /
[email protected]</author>
<file name="catalog/controller/product/search.php">
<operation>
<search position="replace" offset="1"><![CDATA[
$this->response->setOutput($this->render());
]]></search>
<add><![CDATA[
$this->response->setOutput($this->render()); }
function livesearch() {
$search = $this->request->get['search'];
$this->load->model('catalog/product');
$this->load->model('tool/image');
$limit = 10;
$data = array('filter_name' => $search, 'filter_description' => $search, 'start' => 0, 'limit' => $limit);
$products = $this->model_catalog_product->getProducts($data);
$i = 0;
foreach ($products as $product) {
if ($product['image']) {
$results[$i]["img"] = $this->model_tool_image->resize($product['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
} else {
$results[$i]["img"] = "";
}
$results[$i]["name"] = $product["name"];
$results[$i]["href"] = $this->url->link('product/product', 'product_id=' . $product['product_id']);
$i++;
}
if (count($results) >= $limit) {
$results[] = array(
"img" => "",
"name" => '<p class="more">More...</p>',
"href" => $this->url->link('product/search', 'description=true&search=' . $search)
);
}
if (isset($results)) {
echo json_encode($results);
} else {
echo json_encode("");
}
}
]]></add>
</operation>
</file>
<file name="catalog/view/theme/*/template/common/footer.tpl">
<operation>
<search position="replace"><![CDATA[
</body></html>
]]></search>
<add><![CDATA[
<script>
$(function(){
var i = (!!$("#livesearch").length ? $("#livesearch") : $("<ul id='livesearch'></ul>") ), s = $("#header [name=search]");
function repositionLivesearch() { i.css({ top: (s.offset().top+s.outerHeight()), left:s.offset().left, width: s.outerWidth() }); }
$(window).resize(function(){ repositionLivesearch(); });
s.keyup(function(e){
switch (e.keyCode) {
case 13:
$(".active", i).length && (window.location = $(".active a", i).attr("href"));
return false;
break;
case 40:
($(".active", i).length ? $(".active", i).removeClass("active").next().addClass("active") : $("li:first", i).addClass("active"))
return false;
break;
case 38:
($(".active", i).length ? $(".active", i).removeClass("active").prev().addClass("active") : $("li:last", i).addClass("active"))
return false;
break;
default:
var query = s.val();
if (query.length > 2) {
$.getJSON(
"<?php echo HTTP_SERVER; ?>?route=product/search/livesearch&search=" + query,
function(data) {
i.empty();
$.each(data, function( k, v ) { i.append("<li><a href='"+v.href+"'><img src='"+v.img+"' alt='"+v.name+"'><span>"+v.name+"</span></a></li>") });
i.remove(); $("body").prepend(i); repositionLivesearch();
}
);
} else {
i.empty();
}
}
}).blur(function(){ setTimeout(function(){ i.hide() },500); }).focus(function(){ repositionLivesearch(); i.show(); });
});
</script>
<style>
[name=search] {
outline: none;
}
#livesearch, #livesearch * {
margin: 0;
padding: 0;
list-style: none;
}
#livesearch {
position: absolute;
width: 200px;
top: 0px;
background: #ffffff;
z-index: 100;
box-shadow: 0px 10px 30px rgba(0,0,0,.5);
}
#livesearch li {
border-top: 1px solid #eeeeee;
}
#livesearch a {
display: block;
clear: both;
overflow: hidden;
line-height: 25px;
padding: 10px;
}
#livesearch a:hover, #livesearch li.active a {
background: #38B0E3;
color: #ffffff;
}
#livesearch img {
float: left;
width: 50px;
height: 50px;
margin-right: 10px;
}
#livesearch img[src=''] {
display: none;
}
.more {
text-align: center;
}
</style>
</body></html>
]]></add>
</operation>
</file>
</modification>
Надеюсь поможете