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)
-   -   Listing newest added product first (https://forum.x-cart.com/showthread.php?t=18788)

fractalspin 03-22-2006 04:40 PM

Quote:

Originally Posted by Amy


same here: http://www.fractalspin.com/x/home.php?cat=7

any thoughts?

bestdata 03-30-2006 02:45 PM

sort by pirce desc
 
any idea to get it to sort be price from high to low price

Thanks

shan 03-31-2006 04:20 AM

try change

DESC

for

$direction

fractalspin 03-31-2006 08:44 AM

It's still not working--yes, when you click it once you can get it to sort with the newest first, but it doesn't sort like the other ones do. I think there is a problem with the code. It doesn't sort ASC or DESC.

bestdata 03-31-2006 03:59 PM

sort by price
 
thanks shan
I tried it but did not work.
How about takaing out the mod and having to show products sorted first by price form highest to lowest price.

Any advise will be appreciated.

thanks

lachild 08-03-2006 08:04 AM

Works Perfectly in 4.1.2
 
Thanks for the mod I did have to change one line to get the sort by working correctly.

As noted by Shan in an earlier post I changed the following line:

Code:

            case "add_date":
            $sort_string = "$sql_tbl[products].add_date DESC";
            break;


to this
Code:

            case "add_date":
            $sort_string = "$sql_tbl[products].add_date $direction";
            break;


Works great! Thanks again

Update:

Mod did not by default change to dispay by date. I found that I had to update the products_order feild in the Config table within the datebase.

Use the following SQL command to get the new Date module as an option in the admin section.

Code:

UPDATE `xcart_config` SET `variants` = 'productcode:lbl_sku title:lbl_product orderby:lbl_default price:lbl_price add_date:lbl_date ' WHERE `name` = 'products_order' LIMIT 1 ;

fractalspin 08-06-2006 11:35 AM

Quote:

Thanks for the mod I did have to change one line to get the sort by working correctly.

As noted by Shan in an earlier post I changed the following line:

Code:

case "add_date":
$sort_string = "$sql_tbl[products].add_date DESC";
break;



to this
Code:

case "add_date":
$sort_string = "$sql_tbl[products].add_date $direction";
break;




When I made that change I got this DB Error:

Code:

INVALID SQL: 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 xcart_featured_products, xcart_products_categories, xcart_categories LEFT JOI' at line 1
SQL QUERY FAILURE: SELECT COUNT(xcart_products.productid), MIN(xcart_pricing.price) as price , xcart_products_lng.product as product_lng, xcart_products_lng.descr as descr_lng, xcart_products_lng.full_descr as fulldescr_lng, IF(xcart_variants.variantid IS NOT NULL,'Y','') as is_variant, IF(xcart_classes.classid IS NOT NULL,'Y','') as is_product_options, MIN(v_pricing.price) as v_price, xcart_products_lng.product as product_lng, xcart_products_lng.descr as descr_lng, xcart_products_lng.full_descr as fulldescr_lng, IF(xcart_variants.variantid IS NOT NULL,'Y','') as is_variant, IF(xcart_classes.classid IS NOT NULL,'Y','') as is_product_options, MIN(v_pricing.price) as v_price FROM xcart_products, xcart_pricing 1 xcart_featured_products, xcart_products_categories, xcart_categories LEFT JOIN xcart_products_lng ON xcart_products_lng.productid = xcart_products.productid AND xcart_products_lng.code = 'US' LEFT JOIN xcart_classes ON xcart_classes.productid = xcart_products.productid LEFT JOIN xcart_variants ON xcart_variants.productid = xcart_products.productid LEFT JOIN xcart_pricing as v_pricing ON v_pricing.variantid = xcart_variants.variantid AND v_pricing.quantity = 1 AND v_pricing.membership IN ('','') WHERE xcart_products.productid=xcart_featured_products.productid AND xcart_featured_products.avail='Y' AND xcart_featured_products.categoryid='2' AND xcart_pricing.productid=xcart_products.productid AND xcart_pricing.quantity=1 AND xcart_pricing.membership IN ('','') AND xcart_products.product_type <> 'C' AND xcart_products.product_type <> 'B' AND xcart_pricing.variantid = 0 AND xcart_products_categories.productid=xcart_products.productid AND xcart_products_categories.categoryid = xcart_categories.categoryid AND xcart_categories.membership IN ('','') AND xcart_products.forsale='Y'xcart_pricing.productid=xcart_products.productid AND xcart_pricing.quantity=1 AND xcart_pricing.membership IN ('','') AND xcart_products.product_type <> 'C' AND xcart_products.product_type <> 'B' AND xcart_pricing.variantid = 0 AND xcart_products_categories.productid=xcart_products.productid AND xcart_products_categories.categoryid = xcart_categories.categoryid AND xcart_categories.membership IN ('','') AND xcart_products_categories.categoryid='2' AND (xcart_products_categories.main='Y' OR xcart_products_categories.main!='Y') AND xcart_products.forsale='Y' GROUP BY xcart_products.productid

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/fracta5/public_html/x/include/func.php on line 102


weird, right?[/quote]

admintds 08-08-2006 06:52 AM

Great and easy mod...I'm all about easy! Works like a charm! Thank you !!!

lachild 08-09-2006 12:59 PM

Incorrect Answer... Deleted.

lachild 08-09-2006 01:11 PM

fractalspin,

Your problem is right here...

Code:

xcart_pricing 1 xcart_featured_products,

This means while the $direction is working its not being translated...

Might try something like this..
Code:

case "add_date":

if ($direction == '1'){
    $direction_var = 'DESC';
}

if ($direction == '0') {
    $direction_var = 'ASC';
}
$sort_string = "$sql_tbl[products].add_date $direction_var";
break;



All times are GMT -8. The time now is 07:03 PM.

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