简体   繁体   中英

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. 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. Since the upgrade to 1.5.6.1 header search isn't returning any results.

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 .

But if I modify the same returned link to include filter_name then it shows up results as expected. 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 forum link

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

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:

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

I get same problem after removing <base> tag. To fix edit catalog/view/javascript/common.js . Replace:

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

with:

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

Another aproach to fix it using .htaccess:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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