Magento Forum

   
creating a list based on an attribute
 
magelover
Member
 
Total Posts:  36
Joined:  2008-09-19
 

Hi everyone

First of all, big thanks to the Magento Team for such a wonderful system - it’s an honour to be able to use a system like this - and for free! -

I looked through the forums and even though people mentioned this subject before - I didn’t find an answer - so this might be useful to many out there....

I’m currently trying to create a list of products (grid or list) based only on specific attributes. e.g. Manufacturers -. In my case, I’m using the type of products as categories - but I want to have a left navigation menu - for example, ‘shop by Manufacturers’ which should have a navigation list of the available manufacturers in my store, and when clicked this would display all products that share the same attribute in a grid/list view

Please help me with this - I’ve worked already on this for over 5 hours and still I haven’t been succesful

Hoping someone out there would help me, regards

Magelover

 
Magento Community Magento Community
Magento Community
Magento Community
 
magelover
Member
 
Total Posts:  36
Joined:  2008-09-19
 

could anyone please just give at least a clue...and if there’s anything in another thread that I haven’t found please don’t hesitate. All comments welcome!

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
shopwoc
Member
 
Total Posts:  45
Joined:  2008-10-07
 

I’ve been searching for an answer to this problem as well and have been unsuccessful.  It seems like something that many Magento users would need to do.  Any help is greatly appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 

@magelover
Have you checked out layered navigation? Sounds exactly like what you are attempting to achieve.

 
Magento Community Magento Community
Magento Community
Magento Community
 
shopwoc
Member
 
Total Posts:  45
Joined:  2008-10-07
 

Layered navigation does list the manufacturers once you click on a category but I think what we are trying to do (or at least me) is show a list of the manufacturers at all times not just in the layered nav.  Any ideas?

PS
Love your site Fido, it’s been very helpful already.  Keep posting.  Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
shopwoc
Member
 
Total Posts:  45
Joined:  2008-10-07
 

I found how to list an attribute (in this case the manufacturer) It’s easy to change depending on the attribute. I haven’t been able to make them links to all the products for the particular designer so if anyone knows that please post it here.  Thanks.

Put this function in the Block:

public function getAllManu()     {       $product Mage::getModel('catalog/product');       $attributes Mage::getResourceModel('eav/entity_attribute_collection')                   ->setEntityTypeFilter($product->getResource()->getTypeId())                   ->addFieldToFilter('attribute_code''manufacturer');       $attribute $attributes->getFirstItem()->setEntity($product->getResource());       $manufacturers $attribute->getSource()->getAllOptions(false);       return $manufacturers;                   }

Put this in the template(you can make it a dropdown by just changing your html if you wish):

<ul id="manufacturer_list">     <?php foreach ($this->getAllManu() as $manufacturer): ?>          <li><?php echo $manufacturer['label'] ?></li>     <?php endforeach; ?> </ul>

 
Magento Community Magento Community
Magento Community
Magento Community
 
shopwoc
Member
 
Total Posts:  45
Joined:  2008-10-07
 

I found how to list an attribute (in this case the manufacturer) It’s easy to change depending on the attribute. I haven’t been able to make them links to all the products for the particular designer so if anyone knows that please post it here.  Thanks.

Put this function in the Block:

public function getAllManu()     {       
$product 
Mage::getModel('catalog/product');       
$attributes Mage::getResourceModel('eav/entity_attribute_collection')
    ->
setEntityTypeFilter($product->getResource()->getTypeId())
    ->
addFieldToFilter('attribute_code''manufacturer');      
$attribute $attributes->getFirstItem()->setEntity($product->getResource());       
$manufacturers $attribute->getSource()->getAllOptions(false);      
 return 
$manufacturers;                  
 
}

Put this in the template(you can make it a dropdown by just changing your html if you wish):

<ul id="manufacturer_list">    
    
<?php foreach ($this->getAllManu() as $manufacturer): ?>         
        
<li><?php echo $manufacturer['label'] ?></li>     
    
<?php endforeach; ?> 
</ul>

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