if(!empty($params) && $setting1['d_ajax_search_status'] == 1){
$result=$this->model_extension_module_d_ajax_search->search($keyword,$params);
$this->response->setOutput(json_encode($result));
}
и разобрать в этом местеvar result = $.map(results, function (value, index) {
return [value];
});
public function catsInSeacrh(){
if(isset($this->request->get)){
$keyword=$this->request->get['keyword'];
}else{
$keyword='';
}
$this->load->model('catalog/category');
$json = array();
$json['cats'] = array();
$categories = $this->model_catalog_category->getCategoriesForSearch($keyword);
foreach($categories as $category){
$json['cats'][] = array(
'cat_id' => $category['category_id'],
'name' => html_entity_decode($category['name'], ENT_QUOTES, 'UTF-8'),
'url' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
$this->response->setOutput(json_encode($json));
}
$.ajax({
url: $('base').attr('href') + 'index.php?route=extension/module/d_ajax_search/catsInSeacrh&keyword='+keywords,
dataType: 'json',
beforeSend: function () {
},
success: function (data) {
var cats = data.cats,
htmlCats += '<p>Найденные категории</p>';
htmlCats += '<ul>';
for (var i = 0; i < cats.length; i++) {
htmlCats += '<li><a href="'+cats[i]['url']+'">'+cats[i]['name']+'</li>';
console.log(cats[i]["name"]);
}
htmlCats += "</ul>";
$("#d_ajax_search_results_body").prepend(htmlCats);
},
error: function (xhr, textStatus, error) {
console.log(xhr.responseText);
console.log(textStatus);
console.log(error);
}
});
выглядит мощно, но запустить не выходит)