X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Search the products descriptions (https://forum.x-cart.com/showthread.php?t=3436)

toonarific 07-02-2003 11:53 PM

Search the products descriptions
 
Is there a way for admins/customers to be able to search the product descriptions, and not just the product names? This is something I desperately need. Thanx for any assistance given

funkydunk 07-03-2003 12:42 PM

Simple answer: it does already. :lol:

$search_query = "($sql_tbl[products].product like '%$substring%' or $sql_tbl[products].descr like '%$substring%') and $sql_tbl[categories].category like '$search_category%' and $sql_tbl[products].forsale='Y' and $sql_tbl[categories].avail='Y' $price_condition ";

toonarific 07-03-2003 12:47 PM

what file do I plug that snippet into? the current state of the search engine is only looking through the product titles.

kpayne 07-03-2003 12:57 PM

That code is from the standard x-cart distribution. I think the situation may be getting confused by the fact that there are 2 descriptions. In X-Cart, the search page looks at the product names and the short description. However, if you leave the short description blank, when you browse the site, it will use the long description. Just make sure you've got the short description filled in on all of your products.

Hope this helps!

--Kurt

toonarific 07-03-2003 01:08 PM

then how do I change the script to look at the long description too? on many of the products, the text is too cramped in the short description field

jeeya 07-04-2003 03:46 AM

ok
 
You might just want to put key features in short description, because if you put long description, there may be more match for search due to common words, I guess.

Mine is working fine. I sell dvds, and I put release year, actor names, director and it works fine.

You might just want to make some key features like that too make search perfect.

toonarific 07-04-2003 07:53 AM

I sell cartoon videos, and in the full description I list the episodes that are on the tape. That way, if someone is looking for a particular episode, they can find it through a search. However, if I put the episode listing in the short description, it will be too much info listed on the category listings.

How can the code be modified to also search the fulldescr field?

funkydunk 07-04-2003 10:08 PM

Change the search query in customer/search.php from the one I qouted above to:

Code:

$search_query = "($sql_tbl[products].product like '%$substring%' or $sql_tbl[products].descr like '%$substring%' or $sql_tbl[products].fulldescr like '%$substring%') and $sql_tbl[categories].category like '$search_category%' and $sql_tbl[products].forsale='Y' and $sql_tbl[categories].avail='Y' $price_condition ";

that'll do it

toonarific 07-04-2003 10:21 PM

excellent. thanx

jeeya 07-24-2003 04:17 AM

Hi,
Look up to following Website's Search Engine, this website is full of features :idea: Does any one know how to modify search engine just like theirs??

Try to dig in this website you will find lot and lot of features.


http://www.indofilms.com/home/myfilms/language/section/catalog.jsp?BV_SessionID=@@@@0026453303.1059048867 ...hindi&main=yes

funkydunk 07-24-2003 04:30 AM

yes. :lol:

If you want to pm me I will give you a quote for doing it.

Russell 08-03-2003 05:41 PM

Here is the code for my search.php ver.3.4.3. It includes a search of the default descr field as well as a search of fulldescr and param00 which is the first extra field that can be added to each product. The search will also find the items in an advanced search. The added part of each line would be the following
Quote:

or $sql_tbl[products].fulldescr like '%$substring%'
with fulldescr changing to match the field you want to search within. This line is repeated a number of times and it needs to be changed in each place or the search will not work correctly.

Code:

<?
/*****************************************************************************\
+-----------------------------------------------------------------------------+
| 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.44.2.1 2003/06/02 11:57:44 svowl Exp $
#

require "../smarty.php";
require "../config.php";
@include "./https.php";
require "./auth.php";
require "../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)) {
#
# Permorfm SQL search query
#

        $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) {
       
                $substring_query = "AND (($sql_tbl[products].product like '%$substring%' or $sql_tbl[products].fulldescr like '%$substring%' OR $sql_tbl[products].descr like '%$substring%' OR $sql_tbl[products].param00 like '%$substring%') OR ($sql_tbl[products_lng].code='$store_language' AND ($sql_tbl[products_lng].product LIKE '%$substring%' OR $sql_tbl[products_lng].fulldescr LIKE '%$substring%' OR $sql_tbl[products].descr like '%$substring%' OR $sql_tbl[products].param00 like '%$substring%' OR $sql_tbl[products_lng].fulldescr LIKE '%$substring%' OR $sql_tbl[products].descr like '%$substring%' OR $sql_tbl[products].param00 like '%$substring%'}))";

                $search_query_count = "select count(*) from $sql_tbl[pricing], $sql_tbl[categories], $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid 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";

        }
        else {
                $substring_query = "AND ($sql_tbl[products].product like '%$substring%' OR $sql_tbl[products].fulldescr like '%$substring%' OR $sql_tbl[products].descr like '%$substring%' OR $sql_tbl[products].param00 like '%$substring%')";

                $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 ($sql_tbl[products].product like '%$substring%' or $sql_tbl[products].fulldescr like '%$substring%' OR $sql_tbl[products].descr like '%$substring%' OR $sql_tbl[products].param00 like '%$substring%') 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));

#
# Navigation code
#
        $objects_per_page = $config["Appearance"]["products_per_page"];

        $total_nav_pages = ceil($total_products_in_search/$objects_per_page)+1;
        require "../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");
?>



All times are GMT -8. The time now is 02:41 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.