【问题标题】:PHP Notice: Undefined index: filter_name - Opencart 1.5.6.1PHP 通知:未定义索引:filter_name - Opencart 1.5.6.1
【发布时间】:2015-09-13 10:38:33
【问题描述】:

希望有人能帮助我。我正在运行 opencart 1.5.4,并且必须使用新的托管帐户将版本升级到 1.5.6.1。从那以后,我的搜索无法通过标题搜索框进行。

我一直在使用 vqmod,它修改了搜索以包含 AND 而不是 OR,因此它在 1.5.4 的先前版本中返回诸如“hp p1105”(我的网站是打印机墨盒网站)之类的结果。由于升级到 1.5.6.1 标头搜索没有返回任何结果。

举个例子;如果您通过转到new hosting account link 搜索“hp p1005”,它不会显示任何结果并返回http://64.34.75.145/~sydne716/index.php?route=product/search&search=hp%20p1005。

但是,如果我修改相同的返回链接以包含 filter_name,那么它会按预期显示结果。 http://64.34.75.145/~sydne716/index.php?route=product/search&filter_name=hp%20p1005

如果我再次在搜索结果页面中搜索,它会返回所有搜索项。

我曾尝试在 opencart 论坛上发帖,但收到的回复很少,但似乎无助于解决我遇到的问题。 Opencart forum link

我在系统中也遇到以下错误 --> 错误部分

2015-09-13 20:22:20 - PHP 通知:未定义索引:/home/sydne716/public_html/vqmod/vqcache/vq2-catalog_model_catalog_product.php 中的 filter_name 在第 481 行

如果有人可以在这里提供帮助,我将不胜感激。我正在等待使用我的新主机帐户,但如果没有搜索功能,我将无法继续。

谢谢你,感谢任何帮助。

【问题讨论】:

    标签: php search undefined opencart


    【解决方案1】:

    在catalog/view/javascript/common.js更改:

    $('.button-search').bind('click', function() {
        url = $('base').attr('href') + 'index.php?route=product/search';
    
        var search = $('input[name=\'search\']').attr('value');
    
        if (search) {
            url += '&search=' + encodeURIComponent(search);
        }
    
        location = url;
    });
    

    到:

    $('.button-search').bind('click', function() {
        url = $('base').attr('href') + 'index.php?route=product/search';
    
        var search = $('input[name=\'search\']').attr('value');
    
        if (search) {
            // NOTE: search was changed to filter_name
            url += '&filter_name=' + encodeURIComponent(search);
        }
    
        location = url;
    });
    

    对$('#header input[name=\'search\']').bind('keydown', function(e) {做同样的修改

    【讨论】:

    • 感谢您的回复。我的 common.js 已经包含了 $filter_name。
    • 在您提供的页面中没有filter_name。你能重新检查一下吗?您可以通过view source->单击该 common.js 文件进行检查。也许你应该清除服务器上的一些缓存?
    • if (search) { url += '&filter_name=' + encodeURIComponent(search); }
    • 抱歉,我仍然看到 search 而不是 filter_name.. '&search=' + encodeURIComponent(search);。可能你忘记在服务器上推送文件了?
    • 现在一切都好。我必须包括 url = $('base').attr('href') + 'index.php?route=product/search&description=true';作为我的备份文件 common.js。非常感谢您的帮助,并感谢您抽出宝贵时间回复。
    【解决方案2】:

    删除<base> 标签后我遇到了同样的问题。修复编辑catalog/view/javascript/common.js。替换:

    $('base').attr('href')
    

    与:

    location.protocol + "//" + location.host + '/'
    

    另一种使用 .htaccess 修复它的方法:

    # === fix router error ===
    RewriteCond %{QUERY_STRING}  ^(.*)_route_=undefined[^&]*&(.*)$ [NC]
    RewriteRule .* %{REQUEST_URI}?%1%2 [R,L]
    

    【讨论】:

      猜你喜欢
      • 2012-09-26
      • 2011-12-04
      • 2014-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多