CMS MADE SIMPLE FORGE

Products

 

[#6796] Search action when searching custom fields

avatar
Created By: Peter Stubbs (applejack1923)
Date Submitted: Sat Aug 20 11:43:58 -0400 2011

Assigned To: Robert Campbell (calguy1000)
Version: 2.13.1
CMSMS Version: 1.9.2
Severity: Major
Resolution: None
State: Open
Summary:
Search action when searching custom fields
Detailed Description:
Hi Robert

I have set up the search action and included some additional fields to search
which are as text inputs.

If I have in the Products db content the same text for say the description and
the 2 custom fields and for the front search option choose ANY then it returns
in the results screen the same product 11 times.

If I choose all and enter the same text into the product name and description
fields as well as more than one custom field it returns nothing, If you enter
into name and description and  just one custom field the results returned are
correct.

Basically seems like there is an error with searching custom fields if you try
searching more than one field.

If you only search custom fields and it matches for each field it returns the
same product the same number of times as the number of custom fields where
searched.

The general site search works fine.




History

Comments
avatar
Date: 2011-08-21 07:57
Posted By: Peter Stubbs (applejack1923)

I presume this is related to the custom search field issue as discussed the
other day. Let me know who you are getting on and as I mentioned if you want
paying 50% up front then let me know your payment details. I know you have been
busy with 10.1 looks good.
      
avatar
Date: 2011-09-29 11:56
Posted By: Igor (Osvencim)

Hi(sorry for bad English)
There is logical problem in query in search module(do_action). In my case
(database not big :700 items and 10 custom fields) I solved this problem so...

if( !empty($searchdata) )
  {
    //comment old string
//$joins[] = 'LEFT JOIN '.cms_db_prefix().'module_products_fieldvals FV ON
P.id = FV.product_id';
	
$joins[] = 'LEFT JOIN '.cms_db_prefix().'module_products_fieldvals as t1 ON
P.id = t1.product_id';
	
	$i = 1;
	$z = 0;
	
    foreach( $searchdata as $propname => $propval )
      {
		$i++;
		$z++;
		
$joins[] = 'LEFT JOIN '.cms_db_prefix().'module_products_fieldvals as t'.$i.'
ON t1.product_id = '.'t'.$i.'.product_id';
	  
		$where[] = '('.'t'.$z.'.fielddef_id = ? AND '.'t'.$z.'.value REGEXP ?)';
		$qparms[] = $fields[$propname]->id;		
		$qparms[] = $propval;
	
     }
  }

.....


and ading GROUP by operator in this string

if( count($where2) )
  {
    if( count($where) )
      {
		$qu .= ' AND '.implode(' AND ',$where2).' GROUP BY P.id';
		$qc .= ' AND '.implode(' AND ',$where2).' GROUP BY P.id';
      }
    else
      {
		$qu .= ' WHERE '.implode(' AND ',$where2).' GROUP BY P.id';
		$qc .= ' WHERE '.implode(' AND ',$where2).' GROUP BY P.id';
      }
  }
  

      
avatar
Date: 2013-02-28 18:33
Posted By: Prue Rowland (psy)

Thanks Osvencim.  Seems this is still unfixed in Products v2.18.4.

      
avatar
Date: 2013-11-06 06:47
Posted By: dave (davidhans)

Osvencim's fix worked for me as well but since upgrading to latest version of
Products action.do_search.php has changed.  Is there an equivalent mod that
would allow searching for more than one field?
      
Updates

Updated: 2011-09-29 13:38
description: Hi Robert I have set up the search action and included some additional fields to search which are as text inputs. If I have in the Products db content the same text for say the description and the 2 custom fields and for the front search option choo => Hi Robert I have set up the search action and included some additional fields to search which are as text inputs. If I have in the Products db content the same text for say the description and the 2 custom fields and for the front search option choo

Updated: 2011-08-21 07:57
resolution_id: => 5