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

displaying products with higher productID first

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-09-2005, 10:12 PM
 
cotc2001 cotc2001 is offline
 

X-Man
  
Join Date: Feb 2003
Location: Shrewsbury, UK
Posts: 2,351
 

Default displaying products with higher productID first

Ok this is probably something i've overlooked.

But is there a way with products_t.php to display the items with a higher productID first ???

for example productID 234,235,236 will display before 127,126,125 ???

Reason being is that those with a higher productID will always be newer products so i would want those to be displayed first.
__________________
x-cart 4.0.5 (live and heavily modded)
Server: freebsd
Reply With Quote
  #2  
Old 11-10-2005, 05:09 AM
  TelaFirma's Avatar 
TelaFirma TelaFirma is offline
 

X-Adept
  
Join Date: Nov 2002
Location: North Carolina USA
Posts: 930
 

Default

Ok, here is a quick little mod that will do that for you. This will give you a checkbox in Admin (in Appearance Options, right under the Display Order dropdown) that will allow you to check if you want the listing in revere order or not, and it will also change the "Default" order method to ProductID.

Open products.php and look for the lines:

Code:
if(!isset($sort)) $sort = $config["Appearance"]["products_order"]; if(!isset($sort_direction))

Right under this add this code:

Code:
{ if ($config["Appearance"]["product_order_reversed"] == "Y") { $sort_direction = 1; } else { $sort_direction = 0;} }

Open /include/search.php and look for this block of code:

Code:
# Sort the search results... $direction = ($data["sort_direction"] ? "DESC" : "ASC"); switch ($data["sort_field"]) { case "productcode": $sort_string = "$sql_tbl[products].productcode $direction"; break; case "title": $sort_string = "$sql_tbl[products].product $direction"; break; case "orderby": $sort_string = "$sql_tbl[products_categories].orderby $direction"; break; case "quantity": $sort_string = "$sql_tbl[products].avail $direction"; break; case "price": if (!empty($active_modules["Special_Offers"]) && !empty($search_data["products"]["show_special_prices"])) { $sort_string = "x_special_price $direction, price $direction"; } else { $sort_string = "price $direction"; } break; default: $sort_string = "$sql_tbl[products].product"; }

and replace the line

Code:
$sort_string = "$sql_tbl[products].product";

with
Code:
$sort_string = "$sql_tbl[products].productid";



Run this SQL patch in the Patch/Upgrade section
Code:
INSERT INTO `xcart_config` VALUES ('product_order_reversed', 'List products in reversed order', 'Y', 'Appearance', 100, 'checkbox', 'Y');
Reply With Quote
  #3  
Old 11-10-2005, 07:03 AM
 
cotc2001 cotc2001 is offline
 

X-Man
  
Join Date: Feb 2003
Location: Shrewsbury, UK
Posts: 2,351
 

Default

K thanks that worked a treat
__________________
x-cart 4.0.5 (live and heavily modded)
Server: freebsd
Reply With Quote
  #4  
Old 11-10-2005, 07:04 AM
  TelaFirma's Avatar 
TelaFirma TelaFirma is offline
 

X-Adept
  
Join Date: Nov 2002
Location: North Carolina USA
Posts: 930
 

Default

Great!
Reply With Quote
  #5  
Old 06-28-2007, 05:21 PM
  CobaltCat's Avatar 
CobaltCat CobaltCat is offline
 

Senior Member
  
Join Date: Jul 2003
Location: Southern Orygun
Posts: 153
 

Default Re: displaying products with higher productID first

I need something like this for 4.1.6. Anybody know of a way?
__________________
Thanks -
CobaltCat

I would love to change the world, but they won't give me the source code.
Reply With Quote
  #6  
Old 06-23-2014, 09:47 AM
 
david_ygao david_ygao is offline
 

Advanced Member
  
Join Date: Feb 2005
Location: canada
Posts: 40
 

Default Re: displaying products with higher productID first

It works for me, but I have to change after following line:
case "title":
__________________
/David Gao/
X-cart business 5.3.6
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 09:48 AM.

   

 
X-Cart forums © 2001-2020