简体   繁体   English

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

[英]PHP Notice: Undefined index: filter_name - Opencart 1.5.6.1

Hope you someone can help me out here. 希望你能在这里帮助我。 I was running opencart 1.5.4 and had to upgrade version to 1.5.6.1 with a new hosting account. 我正在运行opencart 1.5.4,并且必须使用新的托管帐户将版本升级到1.5.6.1。 Since then my search isn't working through header search box. 从那时起,我的搜索无法通过标题搜索框进行。

I have been using a vqmod which modified search to include AND rather OR, so it returns results such as "hp p1105" (my site is a printer cartridges website) in the previous version of 1.5.4. 我一直在使用vqmod,它修改了搜索以包括AND而不是OR,因此它在1.5.4的早期版本中返回诸如“ hp p1105”(我的网站是打印机墨盒的网站)之类的结果。 Since the upgrade to 1.5.6.1 header search isn't returning any results. 由于升级到1.5.6.1,标头搜索不会返回任何结果。

For an example; 举个例子; if you search "hp p1005" by going to new hosting account link it won't show you any results and return http://64.34.75.145/~sydne716/index.php?route=product/search&search=hp%20p1005 . 如果通过转到新的托管帐户链接搜索“ hp p1005”,它将不会显示任何结果并返回http://64.34.75.145/~sydne716/index.php?route=product/search&search=hp%20p1005

But if I modify the same returned link to include filter_name then it shows up results as expected. 但是,如果我修改了相同的返回链接以包含filter_name,那么它将按预期显示结果。 http://64.34.75.145/~sydne716/index.php?route=product/search&filter_name=hp%20p1005

Also if I search in the search results page again, it returns all search items. 另外,如果我再次在搜索结果页面中搜索,它将返回所有搜索项。

I have tried posting on opencart forum, got few replies but nothing seem to help to resolve the issue I'm having. 我尝试在opencart论坛上发帖,得到的回复很少,但是似乎没有任何帮助解决我遇到的问题。 Opencart forum link Opencart论坛链接

I also get below error in the system --> error section 我也在系统中出现以下错误->错误部分

2015-09-13 20:22:20 - PHP Notice: Undefined index: filter_name in /home/sydne716/public_html/vqmod/vqcache/vq2-catalog_model_catalog_product.php on line 481 2015-09-13 20:22:20-PHP注意:未定义的索引:在第481行的/home/sydne716/public_html/vqmod/vqcache/vq2-catalog_model_catalog_product.php中的filter_name

I would really appreciate if someone can help here. 如果有人可以在这里提供帮助,我将不胜感激。 I'm waiting to use my new hosting account but without search working I can't go ahead. 我正在等待使用新的托管帐户,但是如果没有搜索工作,我将无法继续。

Thank you, and appreciate any help. 谢谢,感谢您的帮助。

In catalog/view/javascript/common.js change: 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;
});

to: 至:

$('.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;
});

Do the same change to $('#header input[name=\\'search\\']').bind('keydown', function(e) { $('#header input[name=\\'search\\']').bind('keydown', function(e) {

I get same problem after removing <base> tag. 删除<base>标记后,我遇到同样的问题。 To fix edit catalog/view/javascript/common.js . 要修复,请编辑catalog/view/javascript/common.js Replace: 更换:

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

with: 与:

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

Another aproach to fix it using .htaccess: 另一个使用.htaccess修复它的方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM