Only show brands with visible products

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
Post Reply
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Only show brands with visible products

Post by Tony Barnes » Thu Feb 21, 2013 5:04 pm

Never looked at the Brands page before, just did, and realised it shows brands that have invisible products. That might be useful for some peopel, but no good for us.

Anyway, open /includes/display/BrandProductListing.php, find:

Code: Select all

$result = $GLOBALS['ISC_CLASS_DB']->Query("SELECT * FROM [|PREFIX|]brands ORDER BY brandname ASC");
Change to:

Code: Select all

$result = $GLOBALS['ISC_CLASS_DB']->Query(" SELECT brandid,
                                                                   brandname,
                                                                   brandpagetitle,
                                                                   brandmetakeywords,
                                                                   brandmetadesc,
                                                                   brandimagefile,
                                                                   brandsearchkeywords
                                                            FROM   (SELECT prodname,
                                                                           Sum(prodvisible) AS total,
                                                                           prodbrandid
                                                                    FROM   [|PREFIX|]products
                                                                    GROUP  BY prodbrandid) AS checker
                                                                   JOIN [|PREFIX|]brands b
                                                                     ON b.brandid = prodbrandid
                                                            WHERE  total > 0
                                                            ORDER  BY brandname ASC");
Your brands page will now only display brands which have at least 1 visible product in them :D

CharlieFoxtrot
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

Re: Only show brands with visible products

Post by CharlieFoxtrot » Wed Mar 06, 2013 12:32 am

Good catch! Great fix! -- I'll have to tinker with this query a little bit... it's not working with ISC 4.07.
ISC 4.0.7

"... and let's be honest that whole "by design" thing is getting old too."

Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: Only show brands with visible products

Post by Tony Barnes » Tue Mar 26, 2013 10:05 am

Cheers - just odd that they would show - well, not that odd given planning standards at Interspire I guess...

Post Reply