我们有opencart 1.5.5.1。与Journal IV主题。我们修改了搜索框功能,以搜索产品型号和产品名称。我们无法理解的是如何让产品模型出现在下拉搜索结果建议列表中。
感谢任何建议,我们对此感到疯狂。我不能提供任何代码片段,因为我还没有找到我应该为此编辑代码的地方:)
编辑解决:journal.js引用此控制器: - serviceUrl:'index.php?route = module / journal_cp / search_products'
所以我尝试更换:
'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')),
与
'name' => strip_tags(html_entity_decode($result['model'], ENT_QUOTES, 'UTF-8')).' - ' .strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')),
好吧,它很脏,但它是一个开始:)
module / journal_cp / search_products中的原始代码,供那些想看的人使用:
public function search_products() {
$json = array();
if (isset($this->request->get['filter_name']) || isset($this->request->get['filter_model']) || isset($this->request->get['filter_category_id'])) {
$this->load->model('catalog/product');
// $this->load->model('catalog/option');
if (isset($this->request->get['filter_name'])) {
$filter_name = $this->request->get['filter_name'];
} else {
$filter_name = '';
}
if (isset($this->request->get['filter_model'])) {
$filter_model = $this->request->get['filter_model'];
} else {
$filter_model = '';
}
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
} else {
$limit = 20;
}
$data = array(
'filter_name' => $filter_name,
'filter_model' => $filter_model,
'start' => 0,
'limit' => $limit
);
$results = $this->model_catalog_product->getProducts($data);
foreach ($results as $result) {
$option_data = array();
$json[] = array(
'product_id' => $result['product_id'],
'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')),
'model' => $result['model'],
'option' => $option_data,
'price' => $result['price'],
'href' => html_entity_decode($this->url->link('product/product', '&product_id=' . $result['product_id']), ENT_QUOTES, 'UTF-8')
);
}
}
$this->response->setOutput(json_encode($json));
}
答案 0 :(得分:0)
Opencart搜索基于jquery,因此您需要在主题中搜索custom.js或类似的东西并从那里开始。这是最常见的设置,但不一定是你的主题,虽然我可以保证在opencart中搜索是基于jquery函数。如果您确认这是您的设置,我还可以在需要时为您提供进一步的帮助。