VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: alexboot on February 24, 2012, 10:26:12 AM

Title: Search not work
Post by: alexboot on February 24, 2012, 10:26:12 AM
Help
After input search string like :  absd-tg  the special ASCII characters "-" (aslo '.' '/' ) is ignored Why?
As a result search comes to the end with crash
Title: Re: Searh not work
Post by: osp on February 24, 2012, 14:08:28 PM
Which version?
Mine 201N + PHP5.3 works, dashes are ignored in a search...
Title: Re: Search not work
Post by: alexboot on February 24, 2012, 14:27:06 PM
Now I will check up
Title: Re: Search not work
Post by: alexboot on February 24, 2012, 14:52:20 PM
Vm 2.0.1.N
PHP 5.3.10
Joomla 1.7.3


All the same does not work
(http://i037.radikal.ru/1202/5b/c1734cdb42e8.jpg)
Title: Re: Search not work
Post by: jjk on February 24, 2012, 19:45:42 PM
I can reproduce that with a similar search. One of the devlopers is looking after that problem
Title: Re: Search not work
Post by: Sergi0 on February 25, 2012, 10:18:49 AM
Hello!
I Have same trouble on 2.0.2 Virtuemart:
I tried to search 165/55r15, but virtuemart use _db->getEscaped to filter any extra characters and after that i have search string 16555r15.
Title: Re: Search not work
Post by: ssustar52 on April 02, 2012, 21:49:56 PM
Quote from: Sergi0 on February 25, 2012, 10:18:49 AM
Hello!
I Have same trouble on 2.0.2 Virtuemart:
I tried to search 165/55r15, but virtuemart use _db->getEscaped to filter any extra characters and after that i have search string 16555r15.


it's not the _db->getEscaped but the use of vmRequest::uword

this function can be edited in /administrator/components/com_virtuemart/helpers/config.php

you can change the regex used.  BUT be EXTREMELY careful!  You could open up security holes by changing this regex.
Title: Re: Search not work
Post by: RobertL on July 15, 2012, 13:50:20 PM
There's a 2 3 part solution for this so far biggest blunder in my opinion in VM2

For Frontend
1. edit plugins/search/virtuemart.php to enable search by SKU

Line 137
$query = "SELECT DISTINCT CONCAT( a.product_name,' (',p.product_sku,')' ) AS title, a.virtuemart_product_id , b.virtuemart_category_id ,   a.product_s_desc   AS text, b.category_name as section,

Change to:
$query = "SELECT DISTINCT CONCAT( a.product_name,' (',p.product_sku,')' ) AS title, a.product_name , p.product_sku , a.virtuemart_product_id , b.virtuemart_category_id ,   a.product_s_desc   AS text, b.category_name as section,

2. edit administrator/components/com_virtuemart/helpers/config.php to allow search by "-" character. This is from rippergr http://forum.virtuemart.net/index.php?topic=101774.0

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

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

3. finally, edit language/en-GB/en-GB.com_virtuemart.ini since message is not defined for COM_VIRTUEMART_SEARCH_RESULTS just add following line anywhere (or in order, no matter). You can edit the message to whatever you want
COM_VIRTUEMART_SEARCH_RESULTS="Search results for"
Title: Re: Search not work
Post by: tampasounds on October 15, 2012, 19:43:04 PM
Thanks Robert works good.
Title: Re: Search not work
Post by: patrik60 on October 16, 2012, 15:20:59 PM
Quote1. edit plugins/search/virtuemart.php to enable search by SKU

Sorry, but this makes absolutely no sense. This is the search plugin for Joomla search and has no influence in the search function of the VM search module. You may either disable or even delete this file. VM search module is still working but will never find products by SKU.

And btw: the search plugin will find products by SKU without this patch.

But anyway thank you for the second tip (2. edit administrator/components/com_virtuemart/helpers/config.php to allow search by "-" character.) This works fine for me!! I hope I won't get in security troubles ;-)