PHP 注意:未定义索引:filter_name - Opencart 1.5.6.1

PHP Notice: Undefined index: filter_name - Opencart 1.5.6.1

希望有人能帮助我。我是 运行 opencart 1.5.4,必须使用新的托管帐户将版本升级到 1.5.6.1。从那时起,我的搜索就无法通过 header 搜索框进行。

我一直在使用 vqmod,它修改了搜索以包含 AND 而不是 OR,所以它 return 的结果如 "hp p1105"(我的网站是一个打印机墨盒网站)在以前的版本中1.5.4.由于升级到 1.5.6.1 header 搜索没有 return 任何结果。

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

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

另外,如果我再次在搜索结果页面中搜索,它return是所有搜索项。

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

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

2015-09-13 20:22:20 - PHP 注意:未定义索引:filter_name in /home/sydne716/public_html/vqmod/vqcache/vq2-catalog_model_catalog_product.php on line 481

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

谢谢您,感谢您的帮助。

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) {

做同样的改变

我在删除 <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]