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
  #1  
Old 12-21-2005, 02:41 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default Listing newest added product first

Add the ability to sort by add_date field along with listing default by this field. Edit include/search.php and locate the following code:

Code:
$sort_fields = array( "productcode" => func_get_langvar_by_name("lbl_sku"), "title" => func_get_langvar_by_name("lbl_product"), "price" => func_get_langvar_by_name("lbl_price"), "orderby" => func_get_langvar_by_name("lbl_default") );

Change to:
Code:
$sort_fields = array( "add_date" => func_get_langvar_by_name("lbl_date"), "productcode" => func_get_langvar_by_name("lbl_sku"), "title" => func_get_langvar_by_name("lbl_product"), "price" => func_get_langvar_by_name("lbl_price"), "orderby" => func_get_langvar_by_name("lbl_default") );

Next locate:
Code:
# # Perform search and display results # $data = array();

After this above code add:

Code:
if(empty($sort)) $sort = "add_date";

Next locate:
Code:
case "productcode": $sort_string = "$sql_tbl[products].productcode $direction"; break;

Above this line add:

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

Thats it! Now all of your product listings by default will show newest products first. As well as Date field has been added to the sort options list under "Date".

Keep in mind, X-Cart admin->General Settings->Apperance: "Select the order in which products should be displayed within a category:" will be ignored with this mod in place.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #2  
Old 12-22-2005, 07:07 AM
 
Impact_1 Impact_1 is offline
 

Advanced Member
  
Join Date: Jan 2005
Posts: 88
 

Default

Thats a nice touch Boomer, thanks
__________________
Version: 4.1.3

One of the largest UK Suppliers of Car Modification Accessories
http://www.impact-styling.com
Reply With Quote
  #3  
Old 12-25-2005, 04:46 PM
 
Amy Amy is offline
 

Senior Member
  
Join Date: Feb 2004
Posts: 147
 

Default

thanks! bookmarked for review later! I have a few other mods to add on that I purchased but this looks great
__________________
X-Cart Pro 4.0.19; Unix

Other:
XAOM
XOffers
XGift Reg

Other Mods:
Customers Who Also Bought, Download Link Regenerate, Easy Checkout, Newest Products, SEO/CDSEO, Marketing Manager Pro, View Wishlist for Providers (custom by xcart), Email New Releases (a fav!), Telefirma's Dynamic Image Generator, Download Links on Invoice
Reply With Quote
  #4  
Old 12-27-2005, 03:13 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default

This is what I have been looking for. It puts the newest products first in the listings! Thanks!
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #5  
Old 12-27-2005, 06:02 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Default

This is nice little useful mode...thanks boomer
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #6  
Old 12-28-2005, 09:45 AM
 
electronics4less electronics4less is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 38
 

Default

Thanks for the free mod B00MER,

Can this mod be editted so products can be sorted by Manufacturers?
__________________
X-cart v4.0.8
Reply With Quote
  #7  
Old 12-28-2005, 11:28 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Quote:
Originally Posted by electronics4less
Can this mod be editted so products can be sorted by Manufacturers?
Since only mfr. id is stored in products table you may need to subselect or require more custom code for such. Unless you want to sort by the manufacturerid itself, instead of the name
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #8  
Old 01-23-2006, 09:30 AM
 
Amy Amy is offline
 

Senior Member
  
Join Date: Feb 2004
Posts: 147
 

Default

one thing we have seen that has been a bit of a nuisance.... when products are updated via CVS and imported they noted as "new" when they really are not new.
__________________
X-Cart Pro 4.0.19; Unix

Other:
XAOM
XOffers
XGift Reg

Other Mods:
Customers Who Also Bought, Download Link Regenerate, Easy Checkout, Newest Products, SEO/CDSEO, Marketing Manager Pro, View Wishlist for Providers (custom by xcart), Email New Releases (a fav!), Telefirma's Dynamic Image Generator, Download Links on Invoice
Reply With Quote
  #9  
Old 03-17-2006, 07:29 PM
 
Amy Amy is offline
 

Senior Member
  
Join Date: Feb 2004
Posts: 147
 

Default

Hmmmm - could I have some help - tried this tonight and works great "almost"!

My date doesn't change from ASC to DESC

http://scrapbookbytes.com/store/manufacturers.php?manufacturerid=22
__________________
X-Cart Pro 4.0.19; Unix

Other:
XAOM
XOffers
XGift Reg

Other Mods:
Customers Who Also Bought, Download Link Regenerate, Easy Checkout, Newest Products, SEO/CDSEO, Marketing Manager Pro, View Wishlist for Providers (custom by xcart), Email New Releases (a fav!), Telefirma's Dynamic Image Generator, Download Links on Invoice
Reply With Quote
  #10  
Old 03-17-2006, 08:24 PM
 
youngvet1 youngvet1 is offline
 

eXpert
  
Join Date: Aug 2005
Posts: 245
 

Default

What changes should be made if you dont want it sorted by default using newest date but you just want it as an option so if they click it it will sort and put newest first. Another wards i want to keep the default to sort alphabetical.
__________________
x-cart version 4.0.14
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 08:53 PM.

   

 
X-Cart forums © 2001-2020