X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   displaying products with higher productID first (https://forum.x-cart.com/showthread.php?t=17867)

cotc2001 11-09-2005 10:12 PM

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.

TelaFirma 11-10-2005 05:09 AM

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');

cotc2001 11-10-2005 07:03 AM

K thanks that worked a treat

TelaFirma 11-10-2005 07:04 AM

Great!

CobaltCat 06-28-2007 05:21 PM

Re: displaying products with higher productID first
 
I need something like this for 4.1.6. Anybody know of a way?

david_ygao 06-23-2014 09:47 AM

Re: displaying products with higher productID first
 
It works for me, but I have to change after following line:
case "title":


All times are GMT -8. The time now is 01:23 PM.

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