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)
-   -   Sort by manufacturer (https://forum.x-cart.com/showthread.php?t=53675)

shorelineoftahoe 05-10-2010 12:12 PM

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!

ADDISON 07-11-2010 07:22 AM

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.

shorelineoftahoe 07-12-2010 07:17 AM

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

proboscidian 11-18-2010 11:10 AM

Re: Sort by manufacturer
 
Any idea for 4.4? I tried to use this but no go.

shorelineoftahoe 11-18-2010 11:36 AM

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!

proboscidian 11-18-2010 12:00 PM

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

shorelineoftahoe 11-22-2010 08:30 AM

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


All times are GMT -8. The time now is 03:47 AM.

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