Help Please to exclude a brand from SQL

For articles specific to version 5.x
Post Reply
karl800
Posts: 35
Joined: Sat Oct 03, 2009 8:43 pm
Location: Staffordshire, UK

Help Please to exclude a brand from SQL

Post by karl800 »

Hi all,
Hope someone can help. Seen this code from
http://www.interspire.com/forum/showthr ... and+images

It basically lets you have your popular brands display as image rather than text, works great. However, I would like to know away to exclude certain brands.
I tried

Code: Select all

NOT IN (brandname)
If anyone knows will be a great help cheers

in the file
/includes/display/shopbybrand.php
look for the code

Code: Select all

$x = 1;
while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
if($x <= 10) {
$GLOBALS['BrandLink'] = BrandLink($row['brandname']);
$GLOBALS['BrandName'] = isc_html_escape($row['brandname']);
$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ShopByBrandItem");
}
++$x;
}
and add the line

$GLOBALS['BrandImg'] = "<img src='http://www.yourdomainname.co.uk/images/ ... ges/".$row['brandimagefile']."'>";

so it looks like

Code: Select all

$x = 1;
while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
if($x <= 10) {
$GLOBALS['BrandLink'] = BrandLink($row['brandname']);
$GLOBALS['BrandName'] = isc_html_escape($row['brandname']);
$GLOBALS['BrandImg'] = "<img src='http://www.yourdomainname.co.uk/images/product_images/".$row['brandimagefile']."'>";
$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ShopByBrandItem");
}
++$x;
}
The sql statement currently reads

Code: Select all

$query = "SELECT brandid, brandname, COUNT(*) AS num
FROM [|PREFIX|]brands b, [|PREFIX|]products p
WHERE p.prodbrandid = b.brandid
AND prodvisible=1
GROUP BY prodbrandid
ORDER BY num DESC, brandname ASC
";
You just need to add brandimagefile

Code: Select all

$query = "SELECT brandimagefile,brandid, brandname, COUNT(*) AS num
FROM [|PREFIX|]brands b, [|PREFIX|]products p
WHERE p.prodbrandid = b.brandid
AND prodvisible=1
GROUP BY prodbrandid
ORDER BY num DESC, brandname ASC
";
then find the file

templates/_master/snippets/shopbybranditem.html

and edit the line from

Code: Select all

<li><a href="%%GLOBAL_BrandLink%%">%%GLOBAL_BrandName%%</a></li>
to

Code: Select all

<li><a href="%%GLOBAL_BrandLink%%">%%GLOBAL_BrandImg%%</a></li>
Post Reply