我们有opencart 1.5.5.1。与期刊IV主题。我们修改了搜索框功能,以搜索产品型号和产品名称。我们无法理解的是如何使产品模型显示在下拉搜索结果建议列表中。
任何感激的建议,我们都会为此发疯。我无法提供任何代码片段,因为我还没有找到应该在哪里编辑代码:)
编辑已解决:journal.js引用此控制器:-serviceUrl:'index.php?route=模块/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')),
好吧,它很脏,但这是一个开始:)
模块/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));
}