Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

phrase search for 3.5.7?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-04-2004, 05:07 PM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default phrase search for 3.5.7?

I'm wondering if there's a way I can get 3.5.7 to search phrases and not just one exact word. I tried this thread: http://forum.x-cart.com/viewtopic.php?t=5971&highlight=advanced+search but got major errors on the search results. Does anyone have a solution for this version? Thank you.
__________________
--------------------
X-Cart Gold 4.1.11
Linux/Apache
--------------------
Reply With Quote
  #2  
Old 06-05-2004, 01:34 PM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default

anyone?
__________________
--------------------
X-Cart Gold 4.1.11
Linux/Apache
--------------------
Reply With Quote
  #3  
Old 06-05-2004, 03:29 PM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,063
 

Default

Hum. Well, it does search for phrases, but the words must be in the exact order you place them.

For example, on my site, if you search for
increase decrease
you get no results, but if you search for
increase or decrease
you get my Inventory Pricing Mod.

It would take a bit of coding to return results for the 1st case. I'm not sure if that improved searching mod does that or not as I've not tried it. Maybe someone else will know.

Wish I could help more.

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #4  
Old 06-08-2004, 06:24 AM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default

When I had 3.4.14, I had the search code changed as described in the link above and it worked perfectly (i.e. it would search any phrase in or out of order perfectly), but not any longer since I upgraded to 3.5.7
__________________
--------------------
X-Cart Gold 4.1.11
Linux/Apache
--------------------
Reply With Quote
  #5  
Old 06-08-2004, 06:27 AM
 
Emerson Emerson is offline
 

X-Man
  
Join Date: Mar 2004
Location: Atlanta, GA
Posts: 2,209
 

Default

The code below was posted on that same thread for 3.5.3 (page 4).
It should work with 3.5.7.

Code:
<?php /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2003 Ruslan R. Fazliev <rrf@rrf.ru> | | All rights reserved. | +-----------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" | | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: http://www.x-cart.com/license.php | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. | | FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.| | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Initial Developer of the Original Code is Ruslan R. Fazliev | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2003 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: search.php,v 1.50 2003/11/12 14:42:07 svowl Exp $ # require "./auth.php"; require $xcart_dir."/include/categories.php"; $tmp=strstr($QUERY_STRING, "$XCART_SESSION_NAME="); if (!empty($tmp)) $QUERY_STRING=ereg_replace("$XCART_SESSION_NAME=([0-9a-zA-Z]*)", "", $QUERY_STRING); if(!empty($QUERY_STRING)) { # # Perform SQL search query # $substring = trim($substring); // LOOK HERE // new bit to split search string into separate words $con = ""; $substr = ""; $and="AND"; if(!$substring) { $substring=" "; } if(!empty($substring)){ // code to strip last s from search string $substring = trim($substring); $start = (strlen($substring)-1); // echo $start; // echo " "; if ((substr($substring,$start,1)=="s")||(substr($substring,$start,1)=="S")){ $substring = substr($substring,0,$start); // echo $substring; } // end of new funkydunk bit $ss = split(" ",$substring); foreach($ss as $s) // nfc - we add support for other fields to search $con[] = "(".$sql_tbl[products].".product like '%".$s."%'"." OR ". $sql_tbl[products].".productcode like '%".$s."%'"." OR ". $sql_tbl[products].".param00 like '%".$s."%'"." OR ". $sql_tbl[products].".descr like '%".$s."%'"." OR ". $sql_tbl[products].".fulldescr like '%".$s."%'"." OR ". $sql_tbl[products].".productid like '%".$s."%'".")"; //$substr .= "&substring=".urlencode($substring); } if(empty($and))$and = "OR"; $substring_query = (!empty($con)) ? " AND (".join(" ".$and." ",$con).") " :" 1 "; // end of new bit $price_condition = $price_search_1?" AND $sql_tbl[pricing].price>='$price_search_1'":""; $price_condition .= $price_search_2?" AND $sql_tbl[pricing].price<='$price_search_2'":""; $price_substring = $price_search_1?"&price_search_1=".urlencode($price_search_1):""; $price_substring .= $price_search_2?"&price_search_2=".urlencode($price_search_2):""; if ($price_condition) $sort_by_price = "price"; if ($in_category) { $search_category = addslashes(array_pop(func_query_first("select category from $sql_tbl[categories] where categoryid='$in_category'"))); $search_categories = func_query("select categoryid from $sql_tbl[categories] where $sql_tbl[categories].category like '$search_category%'"); if(is_array($search_categories)) { $category_condition=" in ( "; foreach($search_categories as $k=>$v) $category_condition .= "'$v[categoryid]', "; $category_condition = ereg_replace(", $", ")", $category_condition); $category_condition=" ($sql_tbl[products].categoryid $category_condition or $sql_tbl[products].categoryid1 $category_condition or $sql_tbl[products].categoryid2 $category_condition or $sql_tbl[products].categoryid3 $category_condition) "; } } else $category_condition = "1"; $membership_condition = " AND ($sql_tbl[categories].membership='". $user_account['membership']."' OR $sql_tbl[categories].membership='') "; if ($store_language != $config["default_customer_language"] && $substring) { // LOOK HERE // nfc - always using default language so this case will never happen } else { // LOOK HERE // nfc - removed $substring_query =..... $search_query_count = "select count(*) from $sql_tbl[products], $sql_tbl[pricing], $sql_tbl[categories] where $sql_tbl[pricing].productid=$sql_tbl[products].productid and $sql_tbl[pricing].quantity=1 and $sql_tbl[products].categoryid=$sql_tbl[categories].categoryid $membership_condition and ($sql_tbl[pricing].membership='". $user_account['membership']."' or $sql_tbl[pricing].membership='') AND $category_condition and $sql_tbl[products].forsale='Y' and $sql_tbl[categories].avail='Y' $price_condition $substring_query group by $sql_tbl[products].productid"; } $search_query = "$category_condition and $sql_tbl[categories].avail='Y' and $sql_tbl[products].forsale='Y' $price_condition $substring_query "; $total_products_in_search = count(func_query($search_query_count)); // put in so that you can find out what the sql query was by adding &test=1 to the end of the search string if ($test){ echo $search_query_count . " "; } // end # # Navigation code # $objects_per_page = $config["Appearance"]["products_per_page"]; $total_nav_pages = ceil($total_products_in_search/$objects_per_page)+1; require $xcart_dir."/include/navigation.php"; $smarty->assign("products",func_search_products($search_query, @$user_account['membership'],$first_page,$total_products_in_search, 0, @$sort_by_price)); $smarty->assign("navigation_script","search.php?substring=".urlencode($substring)."&in_category=".@$in_category."".$price_substring); $HTTP_GET_VARS["substring"] = stripslashes($HTTP_GET_VARS["substring"]); $smarty->assign("main","search"); } else { $smarty->assign("main","advanced_search"); } $smarty->display("customer/home.tpl"); ?>
__________________
Emerson
Total Server Solutions LLC- Quality X-Cart Hosting
Recommended X-Cart Hosting Provider - US and UK servers
Does your host backup your site? We do EVERY HOUR!!!
Shared Hosting | Managed Cloud | Dedicated Servers
Reply With Quote
  #6  
Old 06-08-2004, 07:39 AM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default

I'll give her a try again, thanks.
__________________
--------------------
X-Cart Gold 4.1.11
Linux/Apache
--------------------
Reply With Quote
  #7  
Old 06-08-2004, 07:43 AM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default

Ok, I must have used the wrong one, thanks! It works now.
__________________
--------------------
X-Cart Gold 4.1.11
Linux/Apache
--------------------
Reply With Quote
  #8  
Old 06-08-2004, 07:48 AM
 
Emerson Emerson is offline
 

X-Man
  
Join Date: Mar 2004
Location: Atlanta, GA
Posts: 2,209
 

Default

Cool

You might also try this adding the following:

Find...
Code:
$sql_tbl[products].".param00 like '%".$s."%'"." OR ".

and make it look like...
Code:
$sql_tbl[products].".param00 like '%".$s."%'"." OR ". $sql_tbl[products].".param01 like '%".$s."%'"." OR ". $sql_tbl[products].".param02 like '%".$s."%'"." OR ". $sql_tbl[products].".param03 like '%".$s."%'"." OR ". $sql_tbl[products].".param04 like '%".$s."%'"." OR ". $sql_tbl[products].".param05 like '%".$s."%'"." OR ". $sql_tbl[products].".param06 like '%".$s."%'"." OR ". $sql_tbl[products].".param07 like '%".$s."%'"." OR ". $sql_tbl[products].".param08 like '%".$s."%'"." OR ". $sql_tbl[products].".param09 like '%".$s."%'"." OR ".

This way it will also search in all your extra fields!

You might or might not have a use for it so edit it accordingly
__________________
Emerson
Total Server Solutions LLC- Quality X-Cart Hosting
Recommended X-Cart Hosting Provider - US and UK servers
Does your host backup your site? We do EVERY HOUR!!!
Shared Hosting | Managed Cloud | Dedicated Servers
Reply With Quote
  #9  
Old 06-08-2004, 08:02 AM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default

totally cool, thanks. I'll give it a try. Thanks again.
__________________
--------------------
X-Cart Gold 4.1.11
Linux/Apache
--------------------
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:04 AM.

   

 
X-Cart forums © 2001-2020