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

Customer Search for productcode or productID
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 09-22-2003, 01:35 AM
 
wicoma wicoma is offline
 

Newbie
  
Join Date: Jul 2003
Posts: 7
 

Default Customer Search for productcode or productID

I would like to ennabled Customer Search for productcode and productID

Whats to do?
Reply With Quote
  #2  
Old 09-22-2003, 04:26 AM
  lildawg's Avatar 
lildawg lildawg is offline
 

X-Adept
  
Join Date: Jan 2003
Location: Utah
Posts: 686
 

Default

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.
Reply With Quote
  #3  
Old 09-22-2003, 07:40 AM
 
dealsondeals dealsondeals is offline
 

eXpert
  
Join Date: Dec 2002
Location: Dallas, Texas, USA
Posts: 231
 

Default

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

Glen
__________________
Never understimate stupidity.
--------
X-Cart Version: 3.5.2
Hosting:mind-in-design.net
Configuration: Virtual Dedicated Server || Intel Pentium 4 2.4 GHZ CPU || 1024MB PC2100 DDR RAM || Linux || PHP 4.3.2 || MySQL server 4.0.14
Reply With Quote
  #4  
Old 09-22-2003, 07:54 AM
  lildawg's Avatar 
lildawg lildawg is offline
 

X-Adept
  
Join Date: Jan 2003
Location: Utah
Posts: 686
 

Default

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.
Reply With Quote
  #5  
Old 09-24-2003, 08:12 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

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

Default

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.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #6  
Old 09-24-2003, 08:14 PM
 
jpsowin jpsowin is offline
 

X-Adept
  
Join Date: Sep 2002
Posts: 459
 

Default

Check this out:
http://forum.x-cart.com/viewtopic.php?t=5971&highlight=
__________________
Joshua Sowin
...taking things one TPL at a time.
Reply With Quote
  #7  
Old 09-24-2003, 08:20 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

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

Default

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!
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #8  
Old 09-24-2003, 08:31 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

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

Default

Oops 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).
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #9  
Old 09-25-2003, 07:48 AM
 
Gibberish Gibberish is offline
 

Senior Member
  
Join Date: Sep 2003
Posts: 182
 

Default

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?
Reply With Quote
  #10  
Old 09-25-2003, 12:41 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

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

Default

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.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 03:59 PM.

   

 
X-Cart forums © 2001-2020