0

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));
}
4

1 に答える 1

0

Opencart 検索は jquery に基づいているため、テーマ custom.js などを検索してそこから開始する必要があります。これは最も一般的なセットアップですが、必ずしもあなたのテーマのものではありませんが、opencart での検索が jquery 関数に基づいていることは保証できます。これがお客様の設定であることを確認していただければ、必要に応じてさらにサポートさせていただきます。

于 2014-02-08T18:01:11.433 に答える