VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: MarcoDings on February 09, 2012, 23:10:47 PM

Title: Searching does not match for "special" characters #/- etc. in search string...
Post by: MarcoDings on February 09, 2012, 23:10:47 PM
Hi

Using Joomla 2.51 and VM 2
The search for normal strings seems to work and returns matched products
so searching for 10055501 or VA1932WM return the products with these strings in the product details ( as set up / configured )

Searching for strings such as
NK570AA#ABA
LF24MGSLBM/ZA
SGJBVG-12389

however fails even though the strings are in the product details

searching for substrings of the above ( not including # / - and possibly others ) , say:
NK570AA
LF24MGSLBM

does find the products mentioned

Since these strings represent manufacturer numbers its not logical for the customer to
try these "partials". The limitation of not beeing able to search for " # / - and possibly more"
illudes me why if report it as a BUG ..
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: Milbo on February 10, 2012, 00:39:27 AM
Hmmm this is a problem of a too strict security. Thanks for pointing out. We must find a good mix of forbidden chars and the one we just need, like #,-,_,/ . They are used a typical delimiters.
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: nflmerch on February 10, 2012, 00:55:50 AM
Sorry this isn't the same problem, but the search function is limited in other ways as well.
For instance plurals do not work:
I have many Flasks in my store, but if I type in "FLASKS" it produces no results.   "FLASK" produces all results as expected.

I know I've been told already that it is not in the plans to fix that, but I can't help but point out that something so basic also seems more like a bug.

Imagine how many people go to a website and search, for example, "GREEN BAY PACKERS HATS"  instead of "GREEN BAY PACKERS HAT"..
... almost everyone in the USA!!!   ;)


Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: Milbo on February 10, 2012, 11:39:25 AM
loool nflmerch, sorry, but ehrm, that is absolute standard. Using a search must be also learned and one of the first things I explain people using the first time things like google that it is always better to search for the root of a word and not deflected ones. Btw that is the way the big search engines make money. They invest millions of dollars in algorythm doing that. It is not possible anylonger to test it yourself, but years ago, even google was not able todo that. They started with "Search instead for", after years of showing that, it directly changed the keywords automatically. But that took some years of development. I know already that 3rd party developers write that. But be aware there exists NO generic solution. It must be adjusted to every language.
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: nflmerch on February 10, 2012, 22:58:07 PM
Thanks for the explanation, I understand.   

Also, I discovered the search will find the plural if you name the category as the plural.
So for example, even if I only have one product that is a "Mug" that is in the category "Dinnerware", if I also put it in a category named "Mugs", then the search will find it if someone types in "mugs".
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: MarcoDings on February 11, 2012, 01:47:53 AM
Quote from: Milbo on February 10, 2012, 00:39:27 AM
Hmmm this is a problem of a too strict security. Thanks for pointing out. We must find a good mix of forbidden chars and the one we just need, like #,-,_,/ . They are used a typical delimiters.
Can you point me in the direction ( source files where i can patch this for myself) for the time beeing, knowing it will get solved.
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: MarcoDings on April 02, 2012, 15:55:23 PM
bump..

any progress on this issue "Searching does not match for "special" characters #/- etc. in search string..." ??

I could not find a reference in release notes to date 2.03h

Cheers Marco
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: rippergr on April 26, 2012, 19:33:39 PM
Has anyone fixed that problem?
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: rippergr on May 07, 2012, 15:01:38 PM
I found a solution for this problem. I changed the file config.php in /administrator/components/com_virtuemart/helpers/
in line 812
return mb_ereg_replace('[^\w'.preg_quote($custom).']', '', $source);
to
return mb_ereg_replace('/[^\w'.preg_quote($custom).']/', '', $source);
The problem is that virtuemart search filter all special characters and returns no results.
With this tweak it working great.
I don't know if there is any problem with security issues. Use it with your own responsibility
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: tampasounds on October 15, 2012, 19:38:43 PM
Works 2.0.10 - good hack
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: Jason Farmer on October 17, 2012, 11:07:51 AM
Quote from: rippergr on May 07, 2012, 15:01:38 PM
I found a solution for this problem. I changed the file config.php in /administrator/components/com_virtuemart/helpers/
in line 812
return mb_ereg_replace('[^\w'.preg_quote($custom).']', '', $source);
to
return mb_ereg_replace('/[^\w'.preg_quote($custom).']/', '', $source);
The problem is that virtuemart search filter all special characters and returns no results.
With this tweak it working great.
I don't know if there is any problem with security issues. Use it with your own responsibility


now Line 919 in  /administrator/components/com_virtuemart/helpers/config.php for vm 2.0.12b
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: huntc00 on November 02, 2012, 22:45:14 PM
Above solutions didn't work for me. After trying several option I solved this problem as followed:


I changed:

return mb_ereg_replace('[^\w'.preg_quote($custom).']', '', $source);

To:

return mb_ereg_replace('-/[^\w'.preg_quote($custom).']/-', '', $source);

Now I can use the VM search module to search for productnumbers like: A-100001

Edit: I'm using Joomla 2.5.6 and VM 2.0.12b
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: kittmaster on August 25, 2013, 19:03:23 PM
Quote from: huntc00 on November 02, 2012, 22:45:14 PM
Above solutions didn't work for me. After trying several option I solved this problem as followed:


I changed:

return mb_ereg_replace('[^\w'.preg_quote($custom).']', '', $source);

To:

return mb_ereg_replace('-/[^\w'.preg_quote($custom).']/-', '', $source);

Now I can use the VM search module to search for productnumbers like: A-100001

Edit: I'm using Joomla 2.5.6 and VM 2.0.12b

I'm logging in to confirm that this solution worked for me also when you need to search for wildcards and want to see it in the return results without being stripped out.

The file to mod is as mentioned > /administrator/components/com_virtuemart/helpers/config.php
Title: Re: Searching does not match for "special" characters #/- etc. in search string...
Post by: vixbow on September 18, 2013, 19:43:08 PM
Is there a way to use overrides in the Administrator folder (mentioned above) so that this hack doesn't get overwritten?

Thanks in advance!
Title: Searching does not match for "special" characters #/- etc. in search string...
Post by: datalabsys on December 07, 2017, 00:47:33 AM
VirtueMart 3.0.18
Joomla! 3.8.2

i have exactly the same issue here and im at the latest version of VM and Joomla....and this problem is the same since version 2.... any fixes? The lines you are advising to change do not exist anymore in VM version 3.