Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Adding New Sort By Option

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-05-2009, 01:33 PM
 
mrerotic mrerotic is offline
 

eXpert
  
Join Date: Feb 2009
Posts: 264
 

Default 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
__________________
x-cart 4.2.3
AlteredCart Smart Search
Auto Featured Products Mod (Personal Mod)
BCSE Product Importer Pro & Drop Shipper Pro
CDSEO Pro
CMS EZRecommends
EE slider login (Personal Mod)
Next Prev Link Mod (Customized)
ShadowBox Detailed Images (Personal Mod)
Shop By Price (Customized)
Social Media (Personal Mod)
Switch Layout View (Personal Mod)
Special Offers
Testimonials (Personal Mod)
Whats New (Customized)
Reply With Quote
  #2  
Old 09-14-2009, 09:01 AM
 
mikalou mikalou is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 71
 

Default 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"); }
__________________
X-Cart Gold 4.2.2 - 3.1.19
Reply With Quote

The following 2 users thank mikalou for this useful post:
am2003 (12-31-2010), TheWrongGrape (05-13-2010)
  #3  
Old 09-14-2009, 06:12 PM
 
mrerotic mrerotic is offline
 

eXpert
  
Join Date: Feb 2009
Posts: 264
 

Default 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.
__________________
x-cart 4.2.3
AlteredCart Smart Search
Auto Featured Products Mod (Personal Mod)
BCSE Product Importer Pro & Drop Shipper Pro
CDSEO Pro
CMS EZRecommends
EE slider login (Personal Mod)
Next Prev Link Mod (Customized)
ShadowBox Detailed Images (Personal Mod)
Shop By Price (Customized)
Social Media (Personal Mod)
Switch Layout View (Personal Mod)
Special Offers
Testimonials (Personal Mod)
Whats New (Customized)
Reply With Quote
  #4  
Old 09-15-2009, 05:43 AM
 
mikalou mikalou is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 71
 

Default Re: Adding New Sort By Option

Can you post that query statement.
__________________
X-Cart Gold 4.2.2 - 3.1.19
Reply With Quote
  #5  
Old 09-15-2009, 06:07 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Re: Adding New Sort By Option

What about Sort by Manufacturer?
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #6  
Old 09-15-2009, 01:32 PM
 
mrerotic mrerotic is offline
 

eXpert
  
Join Date: Feb 2009
Posts: 264
 

Default 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
__________________
x-cart 4.2.3
AlteredCart Smart Search
Auto Featured Products Mod (Personal Mod)
BCSE Product Importer Pro & Drop Shipper Pro
CDSEO Pro
CMS EZRecommends
EE slider login (Personal Mod)
Next Prev Link Mod (Customized)
ShadowBox Detailed Images (Personal Mod)
Shop By Price (Customized)
Social Media (Personal Mod)
Switch Layout View (Personal Mod)
Special Offers
Testimonials (Personal Mod)
Whats New (Customized)
Reply With Quote
  #7  
Old 09-15-2009, 01:58 PM
 
mikalou mikalou is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 71
 

Default 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?
__________________
X-Cart Gold 4.2.2 - 3.1.19
Reply With Quote
  #8  
Old 09-15-2009, 02:12 PM
 
mrerotic mrerotic is offline
 

eXpert
  
Join Date: Feb 2009
Posts: 264
 

Default 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?
__________________
x-cart 4.2.3
AlteredCart Smart Search
Auto Featured Products Mod (Personal Mod)
BCSE Product Importer Pro & Drop Shipper Pro
CDSEO Pro
CMS EZRecommends
EE slider login (Personal Mod)
Next Prev Link Mod (Customized)
ShadowBox Detailed Images (Personal Mod)
Shop By Price (Customized)
Social Media (Personal Mod)
Switch Layout View (Personal Mod)
Special Offers
Testimonials (Personal Mod)
Whats New (Customized)
Reply With Quote
  #9  
Old 09-16-2009, 06:27 AM
 
mikalou mikalou is offline
 

Advanced Member
  
Join Date: Jun 2005
Posts: 71
 

Default 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
__________________
X-Cart Gold 4.2.2 - 3.1.19
Reply With Quote

The following user thanks mikalou for this useful post:
programmedia (11-11-2009)
  #10  
Old 10-30-2009, 07:30 AM
 
ScrapOrchard ScrapOrchard is offline
 

eXpert
  
Join Date: Mar 2008
Posts: 243
 

Default 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?
__________________
www.scraporchard.com
X-Cart Pro Version 4.5.5

Altered Cart: One Page Checkout, OnSale, Buy Together, Download Expander, Smart Search, Shop by Filters
Gahela: Gahela Support System
The xCart Store: xBanners, xAccess, xMenus
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 11:53 AM.

   

 
X-Cart forums © 2001-2020