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

Listing newest added product first

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 03-22-2006, 04:40 PM
 
fractalspin fractalspin is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 72
 

Default

Quote:
Originally Posted by Amy

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

any thoughts?
__________________
http://www.fractalspin.com
nerdy jewelry, geekcessories, bags, tshirts and other neat stuff

Xcart Version: 4.0.17, PHP: 4.3.11, MySQL server: 4.1.13-standard-log
Reply With Quote
  #12  
Old 03-30-2006, 02:45 PM
 
bestdata bestdata is offline
 

Member
  
Join Date: Oct 2004
Posts: 14
 

Default sort by pirce desc

any idea to get it to sort be price from high to low price

Thanks
__________________
Online stores . Bestdata.com / Diamondmm.com
X-cart Gold 4.0.13 & 4.0.18 & 4.1
UNIX/LINUX
Reply With Quote
  #13  
Old 03-31-2006, 04:20 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

try change

DESC

for

$direction
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #14  
Old 03-31-2006, 08:44 AM
 
fractalspin fractalspin is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 72
 

Default

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.
__________________
http://www.fractalspin.com
nerdy jewelry, geekcessories, bags, tshirts and other neat stuff

Xcart Version: 4.0.17, PHP: 4.3.11, MySQL server: 4.1.13-standard-log
Reply With Quote
  #15  
Old 03-31-2006, 03:59 PM
 
bestdata bestdata is offline
 

Member
  
Join Date: Oct 2004
Posts: 14
 

Default 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
__________________
Online stores . Bestdata.com / Diamondmm.com
X-cart Gold 4.0.13 & 4.0.18 & 4.1
UNIX/LINUX
Reply With Quote
  #16  
Old 08-03-2006, 08:04 AM
 
lachild lachild is offline
 

Advanced Member
  
Join Date: May 2006
Posts: 92
 

Default 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 ;
__________________
Westin Shafer
Come Together Technologies
http://www.ComeTogetherTechnologies.com
Reply With Quote
  #17  
Old 08-06-2006, 11:35 AM
 
fractalspin fractalspin is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 72
 

Default

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]
__________________
http://www.fractalspin.com
nerdy jewelry, geekcessories, bags, tshirts and other neat stuff

Xcart Version: 4.0.17, PHP: 4.3.11, MySQL server: 4.1.13-standard-log
Reply With Quote
  #18  
Old 08-08-2006, 06:52 AM
 
admintds admintds is offline
 

Newbie
  
Join Date: Aug 2006
Posts: 4
 

Default

Great and easy mod...I'm all about easy! Works like a charm! Thank you !!!
__________________
Gold 4.0.18
Reply With Quote
  #19  
Old 08-09-2006, 12:59 PM
 
lachild lachild is offline
 

Advanced Member
  
Join Date: May 2006
Posts: 92
 

Default

Incorrect Answer... Deleted.
__________________
Westin Shafer
Come Together Technologies
http://www.ComeTogetherTechnologies.com
Reply With Quote
  #20  
Old 08-09-2006, 01:11 PM
 
lachild lachild is offline
 

Advanced Member
  
Join Date: May 2006
Posts: 92
 

Default

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;
__________________
Westin Shafer
Come Together Technologies
http://www.ComeTogetherTechnologies.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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:48 PM.

   

 
X-Cart forums © 2001-2020