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)
-   -   Adding (Mfr.) Sort Fields 4.0.x (https://forum.x-cart.com/showthread.php?t=16119)

B00MER 08-23-2005 02:23 PM

Adding (Mfr.) Sort Fields 4.0.x
 
It seems its fairly easy to add any sort field you like with X-Cart 4.0.x.

Here's how I added manufacturerid to the sort by options.

1) Edit include/search.php find:

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


Replace with:

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"),
        "mfrid"                => func_get_langvar_by_name("lbl_manufacturer")
);


Now in the same file locate:
Code:

                        case "orderby":
                                $sort_string = "$sql_tbl[products_categories].orderby $direction";
                                break;


After this line of code add:

Code:

                        case "mfrid":
                                $sort_string = "$sql_tbl[products].manufacturerid $direction";
                                break;


That's it! Pretty simple and quick, and it works on most all available fields in xcart_products table as well as others if need be. :wink:

Dongan 08-23-2005 10:04 PM

nice and simple mod. thanx boomer.

wiper 12-30-2005 04:01 AM

Strange think in my x-cart is, that its sorting correctly only in product search but the choices of ordering are available in list of products in categories and manufacturers, and here its not working correctly, becouse when I am in specified category and click on manufacturer or date sorting, its searching in whole products and order all products, not only which are in the specified category. Anybody know how to solve this ?

Ahh, I found what was wrong.. I have form action address in search order template search.php, instead of nothink:)

electronics4less 12-30-2005 07:32 AM

Nice one..thanks B00MER

davidsaldana 01-01-2006 07:39 PM

Thanks for the mod.

Does anyone know how to change this to sort by votes? I tried the obvious, but it didnt seem to work at all.

Thedae2k 01-02-2006 10:47 AM

Great mod...any ideas on how to make a drop down to display only the selected manufacturer?

JWait 01-08-2006 12:11 PM

Is there a way to make an additional 'extra field' (or fields) sortable? For instance, we use our own SKU, and would like to add a ManufacturerSKU, and be able to sort by that also. Would this be tough to do?

Slavy 04-18-2006 01:11 PM

I checked my code and it looks different:

$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") ); if($current_area == 'A' || $current_area == 'P') $sort_fields["quantity"] = func_get_langvar_by_name("lbl_quantity"); if (empty($search_data))

And then:

{ 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;

I tried and gave me an error message on line 1.
Does anyone know what to do in this situation? By the way it has been done Б─≤speedup optimizationБ─≥ on my XCart, several months ago.
Thanks
8O


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

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