Author Topic: {SOLVED} backend search on productname. How?  (Read 1644 times)

daniel

  • Beginner
  • *
  • Posts: 41
{SOLVED} backend search on productname. How?
« on: April 06, 2011, 10:46:00 am »
Hello,

It seems that whereas the front-end searches productnames, the backend searches in the product short description (see explaination below). How do I make virtuemart search productnames when searching in the backend?

Kind regards


I have a webshop with about 2000 products. For several reasons it is critical that I can search these products in the back-end on their name.

However, back-end searches result in hardly any products where the front-end does result in lots of products.

Say I look for “1uf” in the front-end. This results in all 32 products I have with “1uf” in their productname (for instance “1uF / 500V Russian”, “1uF / 5000V Plessey Visconol”, “1+3+3+1uF / 600Vdc Cornell-Dubilier”, so all sorts of variations to “1uf”).

However searching the back-end (in virtuemart) it only finds 1 product. This product does not have 1uf in the product name, but product short description.



Joseph Kwan

  • Advanced
  • Full Member
  • *****
  • Posts: 2344
Re: backend search on productname. How?
« Reply #1 on: April 07, 2011, 00:54:20 am »
While backend search is different from frontend search, it still search through product name. Unless you have modifed the code, this sort of behavior is not normal.

Did you select a category before search? In that case, the search will be limited by category.
Joomla/VM Upgrade Services. Problems with your migration? We can help.
Custom extensions to VM. Performance Tuning. Template modifications and advices.
Pay service to make VM work according to your needs. Your Joomla/VM solutions are just a PM away.

daniel

  • Beginner
  • *
  • Posts: 41
Re: backend search on productname. How?
« Reply #2 on: April 07, 2011, 10:19:00 am »
No, that's the weird thing. I did not change anything to the code. Still it only searches in description.

I have another site with which I'm toying around, this is a new install of joomla ecommerce edition (i.e. different from the one I am posting about) and that site does the same, it does not search product name.

?!?

What file is the search code for backend?

Joseph Kwan

  • Advanced
  • Full Member
  • *****
  • Posts: 2344
Re: backend search on productname. How?
« Reply #3 on: April 07, 2011, 17:45:26 pm »
What is the VM version?
Joomla/VM Upgrade Services. Problems with your migration? We can help.
Custom extensions to VM. Performance Tuning. Template modifications and advices.
Pay service to make VM work according to your needs. Your Joomla/VM solutions are just a PM away.

daniel

  • Beginner
  • *
  • Posts: 41
Re: backend search on productname. How?
« Reply #4 on: April 07, 2011, 18:41:07 pm »
1.1.5 stable.

okay. I narrowed it down considerably.

I customized the product.product_list.php page to show two additional columns. These columns are to show two custom fields the vm_product table (stock location and purchase price -- these extra values are added via product.product_form.php and cause no issue).

Using the original product.product_list.php the search function operates like you'd expect. Only in the customized product.product_list.php (to show the two fields in two columns) does the search function mess up. The additions are called 'my_code' and 'inkoopprijs'.

I can't seem to find out where I messed up the script. I will go investigating on and post my results. If there is any body bored out of their minds  :P, or wanting to help, greatly appreciated! I attached the custom page below.



[attachment cleanup by admin]

daniel

  • Beginner
  • *
  • Posts: 41
Re: backend search on productname. How?
« Reply #5 on: April 07, 2011, 19:42:33 pm »
Okay, that's what you get for sloppy coding (i.e. doing things to eager by trail and error. It seems I had some messy code, as you can see below, the 'product.my_code' and 'product.inkoopprijs' have a '(' right after the search_sql.="

removing that resolved my issue.

Code: [Select]
$search_sql = " (#__{vm}_product.product_name LIKE '%$keyword%' OR \n";
$search_sql .= "#__{vm}_product.product_sku LIKE '%$keyword%' OR \n";
$search_sql .= " (#__{vm}_product.my_code LIKE '%$keyword%' OR \n";
$search_sql .= " (#__{vm}_product.inkoopprijs LIKE '%$keyword%' OR \n";
$search_sql .= "#__{vm}_product.product_s_desc LIKE '%$keyword%' OR \n";
$search_sql .= "#__{vm}_product.product_desc LIKE '%$keyword%'";
$search_sql .= ") \n";