Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Loop all products from curent category and subcategories
 
oneal
Jr. Member
 
Total Posts:  7
Joined:  2009-06-10
Santpedor (Barcelona)
 

Hi,

I’m currently modding the product list page in order to show manufacturer logos for products on the current category. I’m only able to loop the products from the current catalog page (limit by total products for page) and I want to loop all products from the current category to show all manufacturers not only the ones of the current page.

This is what I have… if can help someone doing the same:

<div class="logos-cont">
    <
div class="logos">
    
<?php
        
//Show manufacturers logo on product page and use it to filter the results
        //I assume that you have added a manufacturer list on attributes and putt it's logo with the same value name on a logo folder
        
        //define variables and arrays
        
$x 0;
        
$array = array();
        
//for each product take manufacturer name and id. We'll use the id for calling the URL with filtered result by this manufacturer
        
foreach ($_productCollection as $_product):
            
//if this manufacturer is already in the array we skip it, if not we'll put it to the array
            
if(!in_array( array($_product->getData('manufacturer'),$_product->getAttributeText('manufacturer') ),$array)){
                $array[$x][0] 
$_product->getData('manufacturer'); //manufacturer id
                
$array[$x][1] $_product->getAttributeText('manufacturer'); //manufacturer value (name)
                
$x++; // increment array position
            
}
        
endforeach;

        
//function that order multidimensional arrays by one dimension in this case "1" = name of the manufacturers
        
function so($a$b{
            
return (strcmp (strtolower($a[1]), strtolower($b[1])));
        
}
        
        
//sorting array by name
        
uasort($array'so');
        
        
//Print manufacturer logo list
        
$numarray count($array); 
        for(
$i=0;$i <= $numarray-1;$i++)
            
echo '<a href="?manufacturer='.$array[$i][0].'"><img src="'.$this->getSkinUrl('images/logos/' str_replace(' ''_',strtolower($array[$i][1])) . '.gif').'" alt="Ver productos '.$array[$i][1].'" title="Ver productos '.$array[$i][1].'"></a>';
        
}
    ?>
    
</div>
</
div>

Thank you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 

Jordi, can I point your attention to the Improved Navigation extension?
It allow to show featured brands for each category (as well as for whole shop) and have quite a lot of other great features like multiple attributes selections, manufacturer logos in the layered navigation, etc ...

Image Attachments
featured.pngshop-by-brands.pngall-brands.pngattributes-images.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
oneal
Jr. Member
 
Total Posts:  7
Joined:  2009-06-10
Santpedor (Barcelona)
 
Amasty - 03 January 2011 04:15 AM

Jordi, can I point your attention to the Improved Navigation extension?
It allow to show featured brands for each category (as well as for whole shop) and have quite a lot of other great features like multiple attributes selections, manufacturer logos in the layered navigation, etc ...

Hi Amasty and thank you for your advice but this is not what I need. I want to show on a category page all brands logos of the current category. If I have 50 different items but they are from only 4 different brans I need to show 4 logos. Now what I have it’s the way to show the logos for the products that I’m listing on the current category page (for example 25 items for page) not all the products of the category.

Thank you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 

Jordi, it still doable with the extension, but we will need to modify the featured block a bit (it will be free modification).  Because now the featured brands block gets manufacturers from all store and you need to get them from the one category (the selected one) only.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top