首页 > 解决方案 > Opencart SEO 模块搜索问题

问题描述

激活 SEO 后,搜索栏中的搜索功能出现问题,每次搜索都找不到页面

没有激活 SEO 搜索工作正常

我注意到在此示例中使用关键字 iphone 的区别如下

https://www.example.com/se/product/search?search=iphone(在设置中禁用 SEO 搜索链接看起来像这样并且有效)

https://www.example.com/product/searchiphone(在设置搜索链接中启用了 SEO 看起来像这样并且不起作用)

启用的 SEO 看起来像这个 searchiphone,而禁用的 SEO 搜索工作 search?search=iphone

如果有人可以帮助我找到要更改的正确行,那么使用 SEO 激活的搜索会从搜索更改为搜索?搜索 =

我已经从与搜索产品相关的文件中添加了代码

    <!-- Search -->
<file path="catalog/controller/product/search.php">
    <operation>
        <search><![CDATA[function index() {]]></search>
        <add position="before"><![CDATA[
            private function _decodeSearchKeyword() {
                $name = 'search';

                if( ! isset( $this->request->get[$name] ) ) {
                    $name = $name == 'filter_name' ? 'search' : 'filter_name';
                    
                    if( ! isset( $this->request->get[$name] ) )
                        return '';
                }

                $search = urldecode( $this->request->get[$name] );

                return str_replace( 'Ow==', ';', $search );
            }
        ]]></add>
    </operation>
</file>

    <file path="catalog/controller/product/search.php">
    <operation>
        <search><![CDATA[$search = $this->request->get['search'];]]></search>
        <add position="replace"><![CDATA[
            $search = $this->_decodeSearchKeyword();
        ]]></add>
    </operation>
    <operation>
        <search><![CDATA[$tag = $this->request->get['search'];]]></search>
        <add position="replace"><![CDATA[
            $tag = $this->_decodeSearchKeyword();
        ]]></add>
    </operation>
    
    <operation>
        <search><![CDATA[$this->document->setTitle($this->language->get('heading_title') .  ' - ' . $this->request->get['search']);]]></search>
        <add position="replace"><![CDATA[
            $this->document->setTitle($this->language->get('heading_title') .  ' - ' . $this->_decodeSearchKeyword());
        ]]></add>
    </operation>
    <operation>
        <search><![CDATA[urlencode(html_entity_decode($this->request->get['search'], ENT_QUOTES, 'UTF-8'))]]></search>
        <add position="replace"><![CDATA[urlencode(html_entity_decode($this->_decodeSearchKeyword(), ENT_QUOTES, 'UTF-8'))]]></add>
    </operation>
    <operation>
        <search><![CDATA[$data['heading_title'] = $this->language->get('heading_title') .  ' - ' . $this->request->get['search'];]]></search>
        <add position="replace"><![CDATA[$data['heading_title'] = $this->language->get('heading_title') .  ' - ' . $this->_decodeSearchKeyword();]]></add>
    </operation>
</file>

    <file path="catalog/controller/product/category.php">
    <operation>
        <search><![CDATA[$this->document->setTitle(]]></search>
        <add position="after"><![CDATA[
        if ( $this->config->get('smp_use_meta_robots') && ( isset($this->request->get['page']) || isset($this->request->get['limit']) || isset($this->request->get['order']) ) ) {
            if( !empty($this->config->get('smp_use_meta_robots_value')) ){
                $this->document->addMeta( 'ROBOTS', $this->config->get('smp_use_meta_robots_value') );
            }
        }
        ]]></add>
    </operation>
</file>

<file path="catalog/controller/product/search.php">
    <operation>
        <search><![CDATA[$this->document->setTitle(]]></search>
        <add position="after"><![CDATA[
            if ( $this->config->get('smp_use_meta_robots') ){
                if( !empty($this->config->get('smp_use_meta_robots_value')) ){
                    $this->document->addMeta( 'ROBOTS', $this->config->get('smp_use_meta_robots_value') );
                }
            }
        ]]></add>
    </operation>
</file>

任何帮助表示赞赏

标签: phpxmlseoopencart

解决方案


推荐阅读