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)
-   -   Order by productcode (https://forum.x-cart.com/showthread.php?t=2501)

ucmarty 04-29-2003 04:43 PM

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.

:?

kpriest 04-30-2003 07:46 AM

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.

ucmarty 04-30-2003 01:40 PM

?
 
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? :?:

kpriest 04-30-2003 02:07 PM

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.

ucmarty 04-30-2003 04:41 PM

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

Cheers :D


All times are GMT -8. The time now is 03:21 AM.

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