Author Topic: [Virtuemart 1.1.9] Search module: change search query  (Read 3649 times)

robertosalemi

  • Jr. Member
  • **
  • Posts: 56
  • Web Programmer
  • Skype Name: robertino_salemi
  • VirtueMart Version: 1.1.2
[Virtuemart 1.1.9] Search module: change search query
« on: December 27, 2013, 18:22:21 pm »
Hello to all,
I need to change the query to search form Search for Virtuemart.

Let me explain my requirement: I have uploaded the products as Product 1, Product 2, Product 3, etc ...

If I search for "Product 1", Virtuemart is "Product 1", but also other elements that contain the terms "Product", however I would like to do a targeted search only on what the user is looking, then "Product 1".

Definitely a split is made of the term entered, instead I should make a LIKE '% Product% 1 ", but how can I make this change?

Thank you.

robertosalemi

  • Jr. Member
  • **
  • Posts: 56
  • Web Programmer
  • Skype Name: robertino_salemi
  • VirtueMart Version: 1.1.2
Re: [Virtuemart 1.1.9] Search module: change search query
« Reply #1 on: December 28, 2013, 10:42:02 am »
I found the code that I am interested in
\web\administrator\components\com_virtuemart\html\shop_browse_queries.php line 85
through the suggestion of a member of another forum.

Code: [Select]
$keywordArr = vmGetCleanArrayFromKeyword( $keyword );

function vmGetCleanArrayFromKeyword just serves to make the explode, so I omitted and written

Code: [Select]
$keywordArr = trim($keyword);
$keywordArr = array($keyword);

It seems to work!

robertosalemi

  • Jr. Member
  • **
  • Posts: 56
  • Web Programmer
  • Skype Name: robertino_salemi
  • VirtueMart Version: 1.1.2
Re: [Virtuemart 1.1.9] Search module: change search query
« Reply #2 on: January 18, 2014, 19:43:32 pm »
Again I ask a little help , I thought I had solved but it was not so !


In summary , I changed the search function like this:
Code: [Select]
$keywordArr = trim($keyword);
$keywordArr = array($keyword);

All this regard this web site  if the search form, write ' Singer 760 ' I saw that he returns the result only if the field is in the column of vm_product product_name , I am interested especially in the field product_desc and query the default is :
Code: [Select]

$sq .= "\n (`#__{vm}_product`.`product_name` LIKE '%$searchstring%' OR ";
$sq .= "\n `#__{vm}_product`.`product_sku` LIKE '%$searchstring%' OR ";
$sq .= "\n `#__{vm}_product`.`product_s_desc` LIKE '%$searchstring%' OR ";
$sq .= "\n `#__{vm}_product`.`product_desc` LIKE '%$searchstring%') ";


for example this product, which has in the description field ' Singer 760 ' does not appear , why?


There is this tag HTML:
<p style="line-height: normal;"><b><span style="font-size: 10pt; font-family: ">SINGER 760</span></b><span style="font-size: 12pt; font-family: " New="New"></span></p>

Why not find it ?
How should I change the search condition ?

Thank you.