opencart 1.5.5.1 があります。ジャーナル 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')),
OK、それは汚れていますが、それは始まりです:)
見たい人のための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));
}