Author Topic: Filter by brand  (Read 3598 times)

Wiz_KeeD

  • Beginner
  • *
  • Posts: 1
Filter by brand
« on: August 05, 2011, 16:01:42 pm »
Hello virtuemart community, this is my first post with greetings and of course a first problem :)

I have noticed that there are several topic regarding this particular subject but to my knowledge and to the extend of my search through the forums my specific version has not been attended to.

The the by-brand filter (which was implemented in 2006 if i'm not mistaking) which features a dropdown menu where you select a brand and it auto-submits with js to get products from a category or subcategory of that specific brand is a good implementation but not exactly what i need.

My job and the clients requirements state that the brands should not be inside a selectbox but rather in a list of hyperlinks with the count of the products inside each brand

So far i have managed to tackle "browse_filterbymf.tpl" and get the names of the brands but not the links or the number of items there since the submission is done by a js function which i havn't identified yet.

If anyone can be so kind as to guide me to a possible module or hack inside the files themselves so i can reach the end result (either by tweaking the queris, making a join of some sort) it would be very much apreciated.

Thank you for your time and glad to be among you all, cheers!

Later edit:

I've managed to do this to get the end result (i know it's terribly ugly and messy) i have no problem with that it's just that it doesn't work with friendly urls this way...any suggestions please?

Code: [Select]
foreach ($res as $manufacturer) {
$selected = '';
if( @$_REQUEST['manufacturer_id'] == $manufacturer->manufacturer_id ) {
$selected = 'selected="selected"';     
}

$nr = new ps_DB;
$nr_query = "
SELECT COUNT(m.product_id) total FROM jos_vm_product_mf_xref m
LEFT JOIN jos_vm_product_category_xref c ON m.product_id = c.product_id
WHERE m.manufacturer_id = " . $manufacturer->manufacturer_id ."
AND c.category_id = " . abs($_GET['category_id']);
$nr->query($nr_query);

$nr_total = $nr->record;

$total_brand = $nr_total[0]->total;

echo "<a onClick='order.submit()' style='color: #FFFFFF;margin-left: 10px;' href='index.php?manufacturer_id=".$manufacturer->manufacturer_id."&Itemid=1&option=com_virtuemart&page=shop.browse&category_id=".abs($_GET['category_id'])."&keyword=&keyword1=&keyword2='>" . $manufacturer->mf_name . "(".$total_brand.")</a>";