Php 在搜索结果下拉式日志中显示产品型号+;敞篷车

Php 在搜索结果下拉式日志中显示产品型号+;敞篷车,php,opencart,journal,Php,Opencart,Journal,我们有opencart 1.5.5.1。第四期杂志的主题。我们修改了搜索框功能,以搜索产品型号和产品名称。我们无法理解的是如何让产品模型出现在下拉搜索结果建议列表中 收到任何感激的建议,我们都会为此发疯。我无法提供任何代码片段,因为我甚至还没有找到应该在哪里编辑此代码:) 编辑已解决:journal.js引用此控制器:-serviceUrl:'index.php?route=module/journal\u cp/search\u products' 所以我试着替换: 'name'

我们有opencart 1.5.5.1。第四期杂志的主题。我们修改了搜索框功能,以搜索产品型号和产品名称。我们无法理解的是如何让产品模型出现在下拉搜索结果建议列表中

收到任何感激的建议,我们都会为此发疯。我无法提供任何代码片段,因为我甚至还没有找到应该在哪里编辑此代码:)

编辑已解决:journal.js引用此控制器:-serviceUrl:'index.php?route=module/journal\u cp/search\u products'

所以我试着替换:

'name'       => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')),

好吧,它很脏,但这是一个开始:)

模块/日志\u cp/search\u产品中的原始代码,用于查找:

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

Opencart搜索基于jquery,因此您需要在themes custom.js或类似内容中搜索,然后从那里开始。这是最常见的设置,但不一定是主题设置,尽管我可以保证opencart中的搜索是基于jquery函数的。如果您能确认这是您的设置,我也可以在需要时进一步帮助您。

你好,Jonid,谢谢。我已经研究了jquery方面的事情,据我所知,它使用jquery.autocomplete.min.js,其中有很多关于autocomplete搜索建议的参考,这正是我们想要更改的值。journal.js的代码涉及控制器/模块/日志/cp/search\u产品-我将补充我的原始问题…从我注意到的情况来看,您已经完成了所需的工作,因此我很高兴能够帮助您。
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));
}