This is kinda neat as it is a little annoying (to me at least) that manufacturers do not have sort orders and there fore can not be listed as per a sort order by default.
so if you're like me, here is a neat little fix that allows you to either sort ALL your manufactures of simply just bring a few to the top of the list (without having to rename them.)
lets assume that you have manufactures id's 1-5
1. Ford
2. Vauxhall
3. Audi
4. Seat
5. Honda
when displayed they will show in this order:
3. Audi
1. Ford
5. Honda
4. Seat
2. Vauxhall
but what if you wanted to have Honda at the top followed by Ford and then everything else..
here's how...
backup includes/templates/YOUR_TEMPLATE/templates/tpl_dynamic_filter.php
open up includes/templates/YOUR_TEMPLATE/templates/tpl_dynamic_filter.php
find this:
and replace with this:PHP Code:$manufacturers = $db->Execute("SELECT manufacturers_id, manufacturers_name, IF(manufacturers_id IN(" . implode(',', $filteredManufacturers) . "), 'Y', 'N') as flag" .
" FROM " . TABLE_MANUFACTURERS .
" WHERE manufacturers_id IN (" . implode(',', $unfilteredManufacturers) . ")" .
" ORDER BY manufacturers_name");
so notice how we are replacing the standard ORDER BY manufacturers_name and now replacing it withPHP Code:$manufacturers = $db->Execute("SELECT manufacturers_id, manufacturers_name, IF(manufacturers_id IN(" . implode(',', $filteredManufacturers) . "), 'Y', 'N') as flag" .
" FROM " . TABLE_MANUFACTURERS .
" WHERE manufacturers_id IN (" . implode(',', $unfilteredManufacturers) . ")" .
" ORDER BY FIELD(manufacturers_id,1,5) DESC");
ORDER BY FIELD(manufacturers_id,1,5) DESC
by doing this we are able to specify the field we wish to sort by, in this case manufacturers_id and then we specify the order starting with the one you want at the very top furthest away.
so in this format:
ORDER BY FIELD({FEILD ID},{forth...},{third},{second},{first}) DESC
so now the order would be:
5. Honda
1. Ford
followed by the rest..
Hope someone finds this of use!![]()


Reply With Quote
