X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Customer Search for productcode or productID (https://forum.x-cart.com/showthread.php?t=4433)

wicoma 09-22-2003 01:35 AM

Customer Search for productcode or productID
 
I would like to ennabled Customer Search for productcode and productID

Whats to do?

lildawg 09-22-2003 04:26 AM

I am not sure but what I actually do is I add the sku before the Title of item so I can enter it into the search when I add products. Example (sh-2170 Sexy Satin Bustier) then if I wanted to look up via Satin Bustier I could or if I just wanted to look by item number I could type sh-2170. I know it isn't an advanced searh as you want but it is how I do it.

dealsondeals 09-22-2003 07:40 AM

:wink: Somtimes a low-tech solution is the way to go.

Glen

lildawg 09-22-2003 07:54 AM

You can say that again. Then you don't have to worry about every month when the new update comes out did they make a change that will kill your customizations.

B00MER 09-24-2003 08:12 PM

Edit customer/search.php:

Code:

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


:!: Note this was done with 3.4.5 and was line 81 to line 92.

This can also be extended and an optional $substring_sku could be added and the advanced search (or basic search) form could have a "product code/sku" field. :wink:

jpsowin 09-24-2003 08:14 PM

Check this out:
http://forum.x-cart.com/viewtopic.php?t=5971&highlight=

B00MER 09-24-2003 08:20 PM

Nice to see a mod that does all words or any words. However that code still doesn't include:

Code:

OR $sql_tbl[products].productcode like '%$substring%'

Which is what search the product code/sku field in the products table ;)

I've also got a sorting mod that can be purchased off www.cartlab.net that makes the sorting of products in the search results. I guess I should update it and add the ability to search the product code as an added bonus.

Anyhow, kudos! :wink:

B00MER 09-24-2003 08:31 PM

Oops 8O forgot you wanted the ProductID's as well, this will work but may return some results with the product ID if some products descriptions contain the product ID number, again this could be a seperate substring variable like $substring_id that could easily be added to the search form as an additional "Search for Product ID" field.

Code:

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


Same lines of code in 3.4.5 (81 to 92).

Gibberish 09-25-2003 07:48 AM

I added the code to search.php so I should be able to search for product code now?

Do I have to add another form and tell it what to look up in advanced_search.tpl? Or was that code built to use the product_title form already there?

EDIT

Also I get this error when I apply the code:

Warning: Division by zero in /usr/www/htdocs/saddlemen/test_site/xcart_test/customer/search.php on line 111


Here is my line 111:

$total_nav_pages = ceil($total_products_in_search/$config["General"]["products_per_page"])+1;

Any Suggestions?

B00MER 09-25-2003 12:41 PM

The code uses the same search field to search for either the product name, description, full description, code/sku, and ID.

What version are you trying to apply the code too?

$total_products_in_search is returning zero, so the math is trying to divide by zero.

hth. ;)


All times are GMT -8. The time now is 08:17 AM.

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