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

Sort by manufacturer

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-10-2010, 12:12 PM
 
shorelineoftahoe shorelineoftahoe is offline
 

Advanced Member
  
Join Date: Jun 2006
Posts: 30
 

Default Sort by manufacturer

I've done this in 4.3, but it should be similar in older versions:

in include/search.php make the following changes:



1) Find these lines right near the top of the file:
"orderby" => func_get_langvar_by_name("lbl_default")
);

And right below that add:

# sort by manufacturer mod begins
if(!$manufacturerid)
$sort_fields["manufacturer"] = func_get_langvar_by_name("lbl_manufacturer"); #sort by manuf mod
# sort by manufacturer mod ends


2) At around line 630 there's a switch case. Right before these lines:

default:
$sort_string = "$sql_tbl[products].product";

Add:

# sort by manufacturer mod begins
case "manufacturer":
$left_joins['manufacturers'] = array(
"on" => "$sql_tbl[manufacturers].manufacturerid = $sql_tbl[products].manufacturerid"
);
$sort_string = "$sql_tbl[manufacturers].manufacturer $direction";
break;
# sort by manufacturer mod ends

3) Make sure to run WWW.YOURSITE.com/cleanup.php
That's it!
__________________
xcart v. 4.18-4.4
Reply With Quote
  #2  
Old 07-11-2010, 07:22 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

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

Default Re: Sort by manufacturer

it is not working for me. "brand" sort option is not appearing near the others. still checking what is going on.

could you post a photo with one of your categories where brand sort link appears?

I think this change will be more effective only if Manufacturer is a drop down list. When choosing a manufacturer, only the items associated with that manufacturer will be listed.
__________________
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
  #3  
Old 07-12-2010, 07:17 AM
 
shorelineoftahoe shorelineoftahoe is offline
 

Advanced Member
  
Join Date: Jun 2006
Posts: 30
 

Default Re: Sort by manufacturer

You can see the mod at work here:
http://rodengray.com/shop/Men.html

What you're describing is a filter, the ability to select a category, then filter the results by brand (only showing one brand at a time). This mod shows all the results, but groups them by the name of the manufacturer alphabetically.

There is a mod that sort of does the opposite of what you describe available for free here:
http://www.bcsengineering.com/store/free-manufacturer-categories-mod.html?&MMCF_xfManuCat

It filters manufacturers by category instead of category by manufacturer.

There's also the Power Filter module, which works on categories only:
http://www.xcartmod.com/cart/product/power-filter.html
__________________
xcart v. 4.18-4.4
Reply With Quote
  #4  
Old 11-18-2010, 11:10 AM
  proboscidian's Avatar 
proboscidian proboscidian is offline
 

Senior Member
  
Join Date: May 2005
Location: Clearwater, FL
Posts: 146
 

Default Re: Sort by manufacturer

Any idea for 4.4? I tried to use this but no go.
__________________
Industrial Webworks
Various xcart versions from 4.1.19 gold - 4.7 gold
http://www.industrialwebworks.net
Reply With Quote
  #5  
Old 11-18-2010, 11:36 AM
 
shorelineoftahoe shorelineoftahoe is offline
 

Advanced Member
  
Join Date: Jun 2006
Posts: 30
 

Default Re: Sort by manufacturer

Here's updated instructions for 4.4:

1) Find these lines right near the top of the file:

$sort_fields = array(
'productcode' => 'lbl_sku',
'title' => 'lbl_product',
'price' => 'lbl_price',
'orderby' => 'lbl_default',
);

And right below that add:

# sort by manufacturer mod begins
if(!$manufacturerid)
$sort_fields["manufacturer"] = 'lbl_manufacturer'; #sort by manuf mod
# sort by manufacturer mod ends


2) At around line 905 there's a switch case. Right before these lines:

default:
$sort_string = "$sql_tbl[products].product";

Add:

# sort by manufacturer mod begins
case 'manufacturer':
$left_joins['manufacturers'] = array(
'on' => "$sql_tbl[manufacturers].manufacturerid = $sql_tbl[products].manufacturerid"
);
$sort_string = "$sql_tbl[manufacturers].manufacturer $direction";
break;
# sort by manufacturer mod ends

3) Make sure to run WWW.YOURSITE.com/cleanup.php
That's it!
__________________
xcart v. 4.18-4.4
Reply With Quote
  #6  
Old 11-18-2010, 12:00 PM
  proboscidian's Avatar 
proboscidian proboscidian is offline
 

Senior Member
  
Join Date: May 2005
Location: Clearwater, FL
Posts: 146
 

Default Re: Sort by manufacturer

Wow! That was a quick answer! Unfortunately, although the sort shows up, clicking on it results in "No products found".

Here's a url: http://industrialwebworks.net/breakers/home.php?cat=22
__________________
Industrial Webworks
Various xcart versions from 4.1.19 gold - 4.7 gold
http://www.industrialwebworks.net
Reply With Quote
  #7  
Old 11-22-2010, 08:30 AM
 
shorelineoftahoe shorelineoftahoe is offline
 

Advanced Member
  
Join Date: Jun 2006
Posts: 30
 

Default Re: Sort by manufacturer

Wow, that was a really dumb mistake on my part. The trouble is with the quotes in step 2. They were single quotes before, and they need to be double quotes. I'm updating the post above and reposting what's changed below:

This:

# sort by manufacturer mod begins
case 'manufacturer':
$left_joins['manufacturers'] = array(
'on' => '$sql_tbl[manufacturers].manufacturerid = $sql_tbl[products].manufacturerid'
);
$sort_string = '$sql_tbl[manufacturers].manufacturer $direction';
break;
# sort by manufacturer mod ends

Should be:

# sort by manufacturer mod begins
case 'manufacturer':
$left_joins['manufacturers'] = array(
'on' => "$sql_tbl[manufacturers].manufacturerid = $sql_tbl[products].manufacturerid"
);
$sort_string = "$sql_tbl[manufacturers].manufacturer $direction";
break;
# sort by manufacturer mod ends
__________________
xcart v. 4.18-4.4
Reply With Quote

The following user thanks shorelineoftahoe for this useful post:
am2003 (11-22-2010)
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 01:00 PM.

   

 
X-Cart forums © 2001-2020