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)

B00MER 12-21-2005 02:41 AM

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.

Impact_1 12-22-2005 07:07 AM

Thats a nice touch Boomer, thanks :)

Amy 12-25-2005 04:46 PM

thanks! bookmarked for review later! I have a few other mods to add on that I purchased but this looks great ;)

JWait 12-27-2005 03:13 AM

This is what I have been looking for. It puts the newest products first in the listings! Thanks! :D

anandat 12-27-2005 06:02 AM

This is nice little useful mode...thanks boomer :D

electronics4less 12-28-2005 09:45 AM

Thanks for the free mod B00MER,

Can this mod be editted so products can be sorted by Manufacturers?

B00MER 12-28-2005 11:28 AM

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

Amy 01-23-2006 09:30 AM

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.

Amy 03-17-2006 07:29 PM

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

youngvet1 03-17-2006 08:24 PM

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.


All times are GMT -8. The time now is 08:00 AM.

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