View Single Post
  #22  
Old 03-27-2012, 09:20 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: Display manufacturer list on category page

Here is a way to do it by cycling through the existing product and manufacturer arrays in php and avoiding adding multiple queries. You can also do it in smarty as Cherie suggests, I just find php to be easier.
in products.php:
Code:
foreach ($products as $k => $v) { $manufac_id = $products[$k]['manufacturerid']; foreach ($manufacturers as $key => $value) { if ((!$manuf_this_cat[$manufac_id])&&($manufacturers[$key]['manufacturerid']==$manufac_id)) {$manuf_this_cat[$manufac_id]=$manufacturers[$key]['manufacturer'];} }} $smarty->assign('manuf_this_cat',$manuf_this_cat);


In subcategories.tpl
Code:
{if $manuf_this_cat} <hr /> <ul> {foreach from=$manuf_this_cat key=k item=v} <li> manufacturerid:{$k}<br /> name:{$v}<br /> link: <a href="manufacturers.php?manufacturerid={$k}">{$v}</a> </li> {/foreach} </ul> <hr /> {/if}


The most efficient way would be to modify the original query for $products to include the manufacturers name by joining the manufacturers table, then you would not have to cycle through the manufacturers array to get the name. But that query is built in kind of a complex way and is used in many places, so, at least for me, it would take some effort to do it and test it.


---


---
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote