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

Order by productcode

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-29-2003, 04:43 PM
 
ucmarty ucmarty is offline
 

Advanced Member
  
Join Date: Mar 2003
Posts: 34
 

Default Order by productcode

Can anyone tell me how to get my products to order by productcode rather than by productid.

Do I need to change an sql query or template or what?

I just can't seem to find where the products are ordered for products.tpl.

Reply With Quote
  #2  
Old 04-30-2003, 07:46 AM
  kpriest's Avatar 
kpriest kpriest is offline
 

eXpert
  
Join Date: Apr 2003
Location: Seattle, WA
Posts: 263
 

Default

In the /xcart/customer/ directory: products.php
Original query:
Code:
# # Get products data for current category and store it into $products array # $search_query = "($sql_tbl[products].categoryid='$cat' or $sql_tbl[products].categoryid1='$cat' or $sql_tbl[products].categoryid2='$cat' or $sql_tbl[products].categoryid3='$cat') and $sql_tbl[products].forsale='Y'";

I believe you just need to add the ORDER BY clause in here, like this:
Code:
# # Get products data for current category and store it into $products array # $search_query = "($sql_tbl[products].categoryid='$cat' or $sql_tbl[products].categoryid1='$cat' or $sql_tbl[products].categoryid2='$cat' or $sql_tbl[products].categoryid3='$cat') and $sql_tbl[products].forsale='Y'" ORDER BY $sql_tbl[products].productcode;
I didn't test this - I have the sort alphabetically mod from somewhere in this forum.

hope this helps.
Reply With Quote
  #3  
Old 04-30-2003, 01:40 PM
 
ucmarty ucmarty is offline
 

Advanced Member
  
Join Date: Mar 2003
Posts: 34
 

Default ?

Thanks for the reply!

That didn't seem to work. I think that there is some other "order by" statement somewhere that might be overriding this attempt to order.

Any other ideas?
Reply With Quote
  #4  
Old 04-30-2003, 02:07 PM
  kpriest's Avatar 
kpriest kpriest is offline
 

eXpert
  
Join Date: Apr 2003
Location: Seattle, WA
Posts: 263
 

Default

Try this for the $search_query code:
Code:
$search_query = "($sql_tbl[products].categoryid='$cat' or $sql_tbl[products].categoryid1='$cat' or $sql_tbl[products].categoryid2='$cat' or $sql_tbl[products].categoryid3='$cat') and $sql_tbl[products].forsale='Y' group by $sql_tbl[products].productid order by $sql_tbl[products].productcode ".($config["General"]["product_order_reversed"]=="Y"?"desc":"asc")." limit $first_page, ".$config["General"]["products_per_page"];

If that doesn't work, look at this thread regarding sorting the products list:
http://forum.x-cart.com/viewtopic.php?t=677

Or this one: http://forum.x-cart.com/viewtopic.php?t=1277
LOTS of info in there - you just have to extrapolate what you need for your purposes.

hope this helps.
Reply With Quote
  #5  
Old 04-30-2003, 04:41 PM
 
ucmarty ucmarty is offline
 

Advanced Member
  
Join Date: Mar 2003
Posts: 34
 

Default Got it!

Thanks for the help. I was able to figure it out using one of those links that you gave me.

Cheers
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 02:23 PM.

   

 
X-Cart forums © 2001-2020