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

show ONLY the brands (attribute) that are used by a product
 
therealro
Sr. Member
 
Total Posts:  102
Joined:  2010-04-09
 

Hi all,

i’m showing a list of brand on a webshop like this:

<?php
            $product 
Mage::getModel('catalog/product');
            
$attributes Mage::getResourceModel('eav/entity_attribute_collection')
            ->
setEntityTypeFilter($product->getResource()->getTypeId())
            ->
addFieldToFilter('attribute_code''brand');
            
$attribute $attributes->getFirstItem()->setEntity($product->getResource());
            
$manufacturers $attribute->getSource()->getAllOptions(false);
        
?>
        <?php $_collectionSize 
count($manufacturers?>
        <?php $i
=0; foreach ($manufacturers as $manufacturer): ?>

My question is, how can i show ONLY the brands that are used by a product?

Example:

I’ve got 3 brands: Nike, Adidas and Reebok.

These 3 brands are now showing on the webshop.
But there are only 2 products in the webshop, and those products use the attribute “Nike” and “Adidas”.

How can i make sure that “Reebok” is not showing in that list and the other 2 do?

Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
therealro
Sr. Member
 
Total Posts:  102
Joined:  2010-04-09
 

Anyone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
therealro
Sr. Member
 
Total Posts:  102
Joined:  2010-04-09
 

Can anyone please help me with this? I’m really stuck :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
kdtips
Member
 
Avatar
Total Posts:  73
Joined:  2011-08-13
Auckland New Zealand
 

Are you trying to use this on product page?

 
Magento Community Magento Community
Magento Community
Magento Community
 
therealro
Sr. Member
 
Total Posts:  102
Joined:  2010-04-09
 

Hi Mageconz,

No i’m trying to do this on the homepage and on the (product) list page.

 
Magento Community Magento Community
Magento Community
Magento Community
 
therealro
Sr. Member
 
Total Posts:  102
Joined:  2010-04-09
 

Can i use something like “isset” to see if the attribute is use by a product, and if so show only those attributes?

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

Hi!

You can get great ‘shop by brand’ functionality with Improved Navigation Extension.
It allows to create brand pages(http://improved-navigation.amasty.com/amd.html). Also with it you can make lists of all brands in nice alphabetically ordered blocks, create the “featured brands” block and have nice short urls for brand pages.

Discover live demo here http://improved-navigation.amasty.com/
See the user guide here http://amasty.com/improved-navigation.html

Image Attachments
imp nav- brands.pngimp nav2.PNGimp nav-alphabetical list of brands.png
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top