VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: lopezalejandro on May 22, 2012, 14:42:21 PM

Title: Search two or more words [SOLVED]
Post by: lopezalejandro on May 22, 2012, 14:42:21 PM
Hi Max!
Thanks for add this!!:
http://forum.virtuemart.net/index.php?topic=101724.0 (http://forum.virtuemart.net/index.php?topic=101724.0)

Whe have another similar problem with the searches.
When we search two or more words it only find results if the words are exacly

Example:
- Search "Sony Vaio" found "Sony Vaio YB3V1E"
- Search "Sony YB3V1E" found nothing!! Because this mach don't are exactly in the product name,  the product name is "Sony Vaio YB3V1E"

We repaired quickly:
in the file administrator/components/com_virtuemart/models/product.php in line 222 aprox.
replace:
$filter_search[] = '`'.$searchField.'` LIKE '.$keyword;
by:
$keywords_plural = preg_replace('/\s+/', '%" AND `'.$searchField.'` LIKE "%', $keyword);
$filter_search[] = '`'.$searchField.'` LIKE '.$keywords_plural;

It's a little reparation, we replace blank space with searchfield:
Array of search fields before:
Array
(
    Array of seach fields after:
Array
(
Thanks!!
Title: Re: Search two or more words [SOLVED]
Post by: alexdixondesign on July 18, 2012, 00:11:43 AM
Very helpful mate, I thought I'd broke it when hacking other parts of the system.

I also trimmed the "\modules\mod_virtuemart_search\tmpl\default.php" file so the SEF URL displayed nicer.

For example - www.example.com/store/search?keyword=2012+AX+PRO


<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>

<!--BEGIN Search Box -->
<form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&search=true&virtuemart_category_id='.$category_id ); ?>" method="get">
<div class="search<?php echo $params->get('moduleclass_sfx'); ?>">
<?php $output '<input style="height:16px;vertical-align :middle;" name="keyword" id="mod_virtuemart_search" maxlength="'.$maxlength.'" alt="'.$button_text.'" class="inputbox'.$moduleclass_sfx.'" type="text" size="'.$width.'" value="'.$text.'"  onblur="if(this.value==\'\') this.value=\''.$text.'\';" onfocus="if(this.value==\''.$text.'\') this.value=\'\';" />'
 
$image JURI::base().'components/com_virtuemart/assets/images/vmgeneral/search.png' ;
 

if ($button) :
    if ($imagebutton) :
        $button '<input type="image" value="'.$button_text.'" class="button'.$moduleclass_sfx.'" src="'.$image.'" onclick="this.form.keyword.focus();"/>';
    else :
        $button '<input type="submit" value="'.$button_text.'" class="button'.$moduleclass_sfx.'" onclick="this.form.keyword.focus();"/>';
    endif;
endif;


echo $output;
?>

</div>
  </form>

<!-- End Search Box -->
Title: Re: Search two or more words [SOLVED]
Post by: Milbo on November 26, 2012, 21:07:28 PM
Idea taken, sorry that we did not add it so long time, but some good member showed me this thread. thanks guys, will be in vm2.0.16 and vm2.1
Title: Re: Search two or more words [SOLVED]
Post by: jillymot on December 13, 2012, 05:24:36 AM
Hi Milbo

Could you please also take a look at the following?

I have noticed that the Virtuemart Search Product module generally works when inputting the search while on a non-virtuemart page, i.e. on a Joomla article page.  I input the search words and it produces the expected result, returning results from multiple categories if the criteria is met.  If, however, I am on a virtuemart category layout page, the expected result will only be returned if I am on the category layout page that product is in, i.e. the product search filters only on that category.  If I try the same search while I am on another category page, it will return a 0 result.  This occurs whether Search Filter Category setting in the module is set to Yes or No - it makes no difference.

Would be great to be able to fix this, as the Virtuemart Search Product results look better than using the standard Joomla search module.

I am using Joomla 2.5.8 Virtuemart 2.0.12b

For example, refer to www.positiveimpact.net.au

From home page enter "oggi" in the Product Search on left.  Two results will be returned.  However if you go to Books category on left and perform same search from there, no results are returned.  I do not wish to limit search just to current category page.

Hope you can help.

Title: Re: Search two or more words [SOLVED]
Post by: nevan on January 07, 2013, 10:49:37 AM
I'm having the same type of problem. Not sure what has happened but my search results are now limited to the category you are in. The Search use to interrogate the entire product database.
Title: Re: Search two or more words [SOLVED]
Post by: PRO on January 07, 2013, 15:04:37 PM
the search module settings have a "category filter" option.

Turn it off
Title: Re: Search two or more words [SOLVED]
Post by: jillymot on January 17, 2013, 06:06:05 AM
Yes PRO, as I explained in my post I have already tried changing the Search Filter Category option in the module to No, but it is still filtering on the category.  Only if I click onto a Joomla content page (rather than a Virtuemart Category Page) and submit the search am I able to get the correct result.

I do not think the Search Filter Category option in the module is working as it should.
Title: Re: Search two or more words [SOLVED]
Post by: furbino on April 12, 2013, 08:45:55 AM
Quote from: lopezalejandro on May 22, 2012, 14:42:21 PM
Hi Max!
Thanks for add this!!:
http://forum.virtuemart.net/index.php?topic=101724.0 (http://forum.virtuemart.net/index.php?topic=101724.0)

Whe have another similar problem with the searches.
When we search two or more words it only find results if the words are exacly

Example:
- Search "Sony Vaio" found "Sony Vaio YB3V1E"
- Search "Sony YB3V1E" found nothing!! Because this mach don't are exactly in the product name,  the product name is "Sony Vaio YB3V1E"

We repaired quickly:
in the file administrator/components/com_virtuemart/models/product.php in line 222 aprox.
replace:
$filter_search[] = '`'.$searchField.'` LIKE '.$keyword;
by:
$keywords_plural = preg_replace('/\s+/', '%" AND `'.$searchField.'` LIKE "%', $keyword);
$filter_search[] = '`'.$searchField.'` LIKE '.$keywords_plural;

Hi there,
I have the same problem with the site of a friend, multiple search doesn't work if there isn't the exact sequential order of the searched words. I changed the product.php as above suggested but I'm unable to find  what is suggested to be repaired below. Any suggestion will be appreciated.
thanks alot.




Quote from: lopezalejandro on May 22, 2012, 14:42:21 PM
It's a little reparation, we replace blank space with searchfield:
Array of search fields before:
Array
(
   

       
  • => `product_name` LIKE "%asus network%"
  • [1] => `product_sku` LIKE "%asus network%"
        [2] => `product_s_desc` LIKE "%asus network%"
        [3] => `category_name` LIKE "%asus network%"
        [4] => `mf_name` LIKE "%asus network%"
    )
Array of seach fields after:
Array
(

       
  • => `product_name` LIKE "%asus%" AND `product_name` LIKE "%network%"
  • [1] => `product_sku` LIKE "%asus%" AND `product_sku` LIKE "%network%"
        [2] => `product_s_desc` LIKE "%asus%" AND `product_s_desc` LIKE "%network%"
        [3] => `category_name` LIKE "%asus%" AND `category_name` LIKE "%network%"
        [4] => `mf_name` LIKE "%asus%" AND `mf_name` LIKE "%network%"
    )
Thanks!!
Title: Re: Search two or more words [SOLVED]
Post by: kittmaster on August 25, 2013, 19:30:07 PM
Quote from: lopezalejandro on May 22, 2012, 14:42:21 PM
Hi Max!
Thanks for add this!!:
http://forum.virtuemart.net/index.php?topic=101724.0 (http://forum.virtuemart.net/index.php?topic=101724.0)

Whe have another similar problem with the searches.
When we search two or more words it only find results if the words are exacly

Example:
- Search "Sony Vaio" found "Sony Vaio YB3V1E"
- Search "Sony YB3V1E" found nothing!! Because this mach don't are exactly in the product name,  the product name is "Sony Vaio YB3V1E"

We repaired quickly:
in the file administrator/components/com_virtuemart/models/product.php in line 222 aprox.
replace:
$filter_search[] = '`'.$searchField.'` LIKE '.$keyword;
by:
$keywords_plural = preg_replace('/\s+/', '%" AND `'.$searchField.'` LIKE "%', $keyword);
$filter_search[] = '`'.$searchField.'` LIKE '.$keywords_plural;

It's a little reparation, we replace blank space with searchfield:
Array of search fields before:
Array
(
   

       
  • => `product_name` LIKE "%asus network%"
  • [1] => `product_sku` LIKE "%asus network%"
        [2] => `product_s_desc` LIKE "%asus network%"
        [3] => `category_name` LIKE "%asus network%"
        [4] => `mf_name` LIKE "%asus network%"
    )
Array of seach fields after:
Array
(

       
  • => `product_name` LIKE "%asus%" AND `product_name` LIKE "%network%"
  • [1] => `product_sku` LIKE "%asus%" AND `product_sku` LIKE "%network%"
        [2] => `product_s_desc` LIKE "%asus%" AND `product_s_desc` LIKE "%network%"
        [3] => `category_name` LIKE "%asus%" AND `category_name` LIKE "%network%"
        [4] => `mf_name` LIKE "%asus%" AND `mf_name` LIKE "%network%"
    )
Thanks!!

This also works perfectly to look for partial strings of products and in my case song searching within the entire website.......well done and thank you!
Title: Search two or more words "out of order" returns zero results
Post by: usermee on September 16, 2013, 23:24:06 PM
Hi, I too am having a similar problem with the search (which has been "fixed" with the code here).

Let's say for instance the product name is "Alan Wake (xbox 360)" and you search for say:

alan wake xbox 360

It will find the product, however, if you now change the order of those words to say:

xbox 360 alan wake or any other variance it will not find the product and return "zero" results.

Anything I can do to fix this problem?

Thanks.
Title: Re: Search two or more words "out of order" returns zero results
Post by: TeeJay.net on January 23, 2014, 09:25:01 AM
Quote from: usermee on September 16, 2013, 23:24:06 PM
Hi, I too am having a similar problem with the search (which has been "fixed" with the code here).

Let's say for instance the product name is "Alan Wake (xbox 360)" and you search for say:

alan wake xbox 360

It will find the product, however, if you now change the order of those words to say:

xbox 360 alan wake or any other variance it will not find the product and return "zero" results.

Anything I can do to fix this problem?

Thanks.

Hi, this problem is still up-to-date. Any information how to fix such issue? The same trouble applies to anything... looking for "red handbag" and "handbag red" goes for totally different search results.
Any help would be appreciated :) Thank you
Title: Re: Search two or more words [SOLVED]
Post by: usermee on January 23, 2014, 09:51:28 AM
Hi there, unfortunately not, I have not had the time to delve into the files to try and fix this. I believe it is your template replacing one of the core search files which is buggy, so what I need to do is go through each template replacement file and swap it out with the original one and see if that works, I am guessing this is what you will need to do as well.
Title: Re: Search two or more words [SOLVED]
Post by: TeeJay.net on January 23, 2014, 18:19:23 PM
Quote from: usermee on January 23, 2014, 09:51:28 AM
Hi there, unfortunately not, I have not had the time to delve into the files to try and fix this. I believe it is your template replacing one of the core search files which is buggy, so what I need to do is go through each template replacement file and swap it out with the original one and see if that works, I am guessing this is what you will need to do as well.

It's definitely not my template. I tried like 5 search modules to test if any of them would work as expected - none of them did. Not only on my site, but on demo webpages of the paid modules as well.

How is this even possible? It worked well on VM1, I have tried it today. You have Apple MacBook in your store, a client types "MacBook Apple" and it won't find anything. Like seriously? Only Joomla search (mod_search) works well for this purpose as well, but it has not the category view layout.
Title: Re: Search two or more words [SOLVED]
Post by: Milbo on January 23, 2014, 22:23:09 PM
Quote from: usermee on September 16, 2013, 23:24:06 PM
Let's say for instance the product name is "Alan Wake (xbox 360)" and you search for say:

alan wake xbox 360

It will find the product, however, if you now change the order of those words to say:

xbox 360 alan wake or any other variance it will not find the product and return "zero" results.

Interesting. We are open for suggestions.
Title: Re: Search two or more words [SOLVED]
Post by: balai on January 24, 2014, 10:21:48 AM
I think that the solution is the joomla's finder. It just needs a plug-in for Virtuemart.

This is exactly what finder does.

It splits the various fields to words and gives a weight to each word. So the results depend on the used words and their weight rather than thei order
Title: Re: Search two or more words [SOLVED]
Post by: TeeJay.net on January 27, 2014, 14:26:18 PM
Quote from: Milbo on January 23, 2014, 22:23:09 PM
Interesting. We are open for suggestions.

So now you have another thing to work on. Joomla search (mod_search) works well, VM1 works well as well, just VM2 is a bit weird in searching.

However, because the VM2 search module searches in both the name and the short description of products, I always somehow put the words of a product's title in a different order into the short description and the search module can find it, then. It's not a very nice solution, though. I guess you can understand.
Title: Re: Search two or more words [SOLVED]
Post by: MekkE on February 17, 2014, 02:12:19 AM
Hi,

(sry for my bad english)

Please someone answer me,:(

I migrate to latest stable VM2/Joomla 2.5 (from VM 1.9.x/J 1.5.x -10.000+ product, 60+ categories..etc), (almost) everything is fine, except the product search.
I enable the standard VM search module + standard vmsearch plugin and ofc enable the plugins in vm config.
In the search plugin admin: I see only one option (search limit), this is normal?

The search module now search only in product title and short description. Search in the full description is very important to me, how/where can I enable this? I reinstall the plugin and the modul, disable seo, etc etc, try everything, but still not work..can u help me pls?:(

Title: Re: Search two or more words [SOLVED]
Post by: balai on February 17, 2014, 10:41:40 AM
 Check the VM configuration. There is a setting for that
Title: Re: Search two or more words [SOLVED]
Post by: MekkE on February 17, 2014, 14:47:04 PM
Thank you very mutch!

umm..Where can I find? I really can't find it :(

edit: Oh dear, oh dear..how can i miss it..im so noob:(:) Found it in Product Order Settings area, thank you!
Title: Re: Search two or more words [SOLVED]
Post by: usermee on August 24, 2015, 10:28:48 AM
Quote from: Milbo on January 23, 2014, 22:23:09 PM
Quote from: usermee on September 16, 2013, 23:24:06 PM
Let's say for instance the product name is "Alan Wake (xbox 360)" and you search for say:

alan wake xbox 360

It will find the product, however, if you now change the order of those words to say:

xbox 360 alan wake or any other variance it will not find the product and return "zero" results.

Interesting. We are open for suggestions.

Hello Milbo, has anyone managed to fix the search function yet or is there a workaround besides replacing the search component completely?
Title: Re: Search two or more words [SOLVED]
Post by: usermee on August 24, 2015, 10:47:40 AM
Fix found here:

http://forum.virtuemart.net/index.php?topic=129146.0