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

Improved Search Function

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #61  
Old 04-28-2004, 12:03 PM
  abeight's Avatar 
abeight abeight is offline
 

X-Adept
  
Join Date: Nov 2003
Location: Cleveland, OH
Posts: 479
 

Default

Awesome mod, funkydunk! I got running on 3.5.0 and made it search a special keywords field that I setup.
__________________
~ Andrea Beight
Reply With Quote
  #62  
Old 04-28-2004, 12:05 PM
 
jeremye jeremye is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Philadelphia, PA
Posts: 158
 

Default

I agree, funkydunk. After updating the search feature, I've received compliments on it nearly 2 hours after going live. Thanks!
__________________
Jeremy
X-Cart Gold v3.4.14 [Linux/Apache]
Heavily Modded
Reply With Quote
  #63  
Old 05-03-2004, 11:41 AM
 
longhorn180 longhorn180 is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Richmond, Virginia
Posts: 187
 

Default

Newbie here and I don't know very much about how to write code so forgive my stupid question. I have version 3.4.14 and inserted this code and it works great. Now for the stupid question, instead of descr., fulldescr, and product id. can I change the search categories to param 00, 01 and so on. I want peaople to be able to search for books by author, isbn or genre and they are extra fields.
Reply With Quote
  #64  
Old 05-03-2004, 11:59 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

yup. any product field in the products table will work.

$sql_tbl[products].param00
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #65  
Old 05-03-2004, 12:43 PM
 
longhorn180 longhorn180 is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Richmond, Virginia
Posts: 187
 

Default

Thanks Boomer for the quick response. I'll give it a try.
Reply With Quote
  #66  
Old 05-03-2004, 02:42 PM
 
longhorn180 longhorn180 is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Richmond, Virginia
Posts: 187
 

Default

I inserted the new fields as param00, param05, and param09. Param00 worked, but the others did not. 00 is author, 05 is isbn and 09 is topic. I can live with it only searching for author, but I'm not sure why the others did'nt work. I do know that those fields do correctly correspond with what is in the database. Is there anything else I'm supposed to insert to make those other fields work?
Reply With Quote
  #67  
Old 05-06-2004, 10:42 AM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default

Anyone see a problem with this code? I cannot find the problem but I think it is in the tpl. I am reading the smarty guide book as I am doing this, but this stuff starts to get confusing.

My php query:

Code:
$brandQuery = "SELECT brand FROM $sql_tbl[products] WHERE forsale='Y' ORDER BY brand"; $brand = func_query($brandQuery); $smarty->assign("brand",$brand);

My Tpl Select:
Code:
<select name=brand> <option selected>All</option> {section name=brand loop=$brand} <option value="{ $brand[brand].brand }">{ $brand[brand].brand|escape }</option> {/section} </select>

This code was taken from a previous post and edited to fit my code, I think written for 3.5.3 and I am on 3.4.14

I am struggling on this one, please help if you can. Thanks
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
  #68  
Old 05-07-2004, 09:44 AM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default

* Figured it all out
__________________
Gibberish
[Unix] X-Cart 4.0.12
Reply With Quote
  #69  
Old 06-26-2004, 11:48 AM
 
junaid junaid is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 96
 

Default

Quote:
Originally Posted by funkydunk
here you go:

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"); ?>
[/code]

Funky dunk You rock..solved my major headache..just works perfect on 3.5.3
__________________
xcart 4.18 on linux
Reply With Quote
  #70  
Old 06-30-2004, 06:27 PM
 
jmell jmell is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 127
 

Default

Hay this code worked great for me.
Anyway to do something to speed up the search in the admin area for product modify product???????
Mine almost always times out before I get anything to come up.
Thinks for the code.
__________________
X-Cart 4.1.9
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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 12:07 PM.

   

 
X-Cart forums © 2001-2020