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

Adding (Mfr.) Sort Fields 4.0.x

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 08-23-2005, 02:23 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default 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.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #2  
Old 08-23-2005, 10:04 PM
  Dongan's Avatar 
Dongan Dongan is offline
 

X-Wizard
  
Join Date: Jul 2005
Location: www.mercuryminds.com
Posts: 1,531
 

Default

nice and simple mod. thanx boomer.
Reply With Quote
  #3  
Old 12-30-2005, 04:01 AM
  wiper's Avatar 
wiper wiper is offline
 

Member
  
Join Date: Dec 2005
Posts: 15
 

Default

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
__________________
Radek Karban - WebDesign - Reklama.cz (not x-cart site)
several x-cart (gold version 4.0.10 - 4.1.3, linux debian) and a huge pack of mods
Reply With Quote
  #4  
Old 12-30-2005, 07:32 AM
 
electronics4less electronics4less is offline
 

Advanced Member
  
Join Date: Jul 2005
Posts: 38
 

Default

Nice one..thanks B00MER
__________________
X-cart v4.0.8
Reply With Quote
  #5  
Old 01-01-2006, 07:39 PM
  davidsaldana's Avatar 
davidsaldana davidsaldana is offline
 

Senior Member
  
Join Date: Oct 2005
Posts: 187
 

Default

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.
__________________
4.4
Code:
Hello World
Reply With Quote
  #6  
Old 01-02-2006, 10:47 AM
 
Thedae2k Thedae2k is offline
 

eXpert
  
Join Date: Jan 2004
Posts: 288
 

Default

Great mod...any ideas on how to make a drop down to display only the selected manufacturer?
__________________
X-Cart Pro 4.1.9
PHP5.2.5
MySQL 5.0.54
IIS/Apache/NGINX Webservers
Reply With Quote
  #7  
Old 01-08-2006, 12:11 PM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default

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?
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #8  
Old 04-18-2006, 01:11 PM
 
Slavy Slavy is offline
 

Member
  
Join Date: Nov 2004
Posts: 19
 

Default

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
__________________
X-Cart
Version 4.6.0
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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 05:55 PM.

   

 
X-Cart forums © 2001-2020