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)
-   -   Adding New Sort By Option (https://forum.x-cart.com/showthread.php?t=49555)

mrerotic 09-05-2009 01:33 PM

Adding New Sort By Option
 
Is there anyway to add a new sort by option? I want to add sort by (Release Date) which is specified in [extra_field_options] table. Can anyone assist me with this?

Thanks

mikalou 09-14-2009 09:01 AM

Re: Adding New Sort By Option
 
You could probably duplicate what I did but substitute the field you want to sort by. I wanted to be able to sort by description. This mod was for X-Cart Gold 4.2.2.

Here is what I did:

Modify: include/search.php
1. Add description into this array. (about line 40) (note: I had to add the lbl_description label in languages)
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"),
        "description"        => func_get_langvar_by_name("lbl_description"),
        "orderby"                => func_get_langvar_by_name("lbl_default")
);

2. Add this new case statement to the switch function for the description field. (about line 600)
Code:

case "description":
        $sort_string = "$sql_tbl[products].descr $direction";
        break;


modify: include/func/func.product.php

1. add description to this array(about line 320)
Code:

        if (is_null($orderby_rules)) {
                $orderby_rules = array (
                        "title" => "product",
                        "quantity" => "$sql_tbl[products].avail",
                        "orderby" => "$sql_tbl[products_categories].orderby",
                        "quantity" => "$sql_tbl[products].avail",
                        "price" => "price",
                        "description" => "$sql_tbl[products].descr",
                        "productcode" => "$sql_tbl[products].productcode");
        }


mrerotic 09-14-2009 06:12 PM

Re: Adding New Sort By Option
 
Thanks for the input, but if I'm searching an extra field, for some reason when I add the extra_field table the query breaks. :(

mikalou 09-15-2009 05:43 AM

Re: Adding New Sort By Option
 
Can you post that query statement.

ADDISON 09-15-2009 06:07 AM

Re: Adding New Sort By Option
 
What about Sort by Manufacturer?

mrerotic 09-15-2009 01:32 PM

Re: Adding New Sort By Option
 
well the problem is I want to orderby release date which comes from table 'extra_field_values' where fieldid="6" order by the 'value' for this extra field. When I add this to the orderby then it does just that orderby, but there is no way of defining the where clause without breaking the mysql query. Any advice? thx

mikalou 09-15-2009 01:58 PM

Re: Adding New Sort By Option
 
Not seeing the query statement I'll just take a couple stabs here at possible probs.

If your query statement joins multiple tables and those tables have some identical field names then you'll need to include the table name (ex: table_name.field_name).
or...
You might need to use a "left join" in your query statement.
or...
orderby should be order by.
or...
where clause needs to proceed order by clause.

Can you post your query statement?

mrerotic 09-15-2009 02:12 PM

Re: Adding New Sort By Option
 
Correct the where clause needs to proceed the orderby clause. But where do I add the where clause for this to proceed it?

mikalou 09-16-2009 06:27 AM

Re: Adding New Sort By Option
 
Try this:

SELECT * FROM $sql_tbl[products] JOIN $sql_tbl[extra_field_values] ON $sql_tbl[extra_field_values].productid = $sql_tbl[products].productid WHERE $sql_tbl[extra_field_values].fieldid='6' ORDER BY $sql_tbl[extra_field_values].value

ScrapOrchard 10-30-2009 07:30 AM

Re: Adding New Sort By Option
 
We have a Date Added modification in place, but would like to figure out how to have just one category sort by product name.. is there anyway to alter the code (which is similar to what was posted in previous replies) to have X-Cart sort one category id by product name and all others by date added?


All times are GMT -8. The time now is 09:52 AM.

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