Magento Forum

   
How can i filter product using attribute? 
 
Creative_Glance
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2008-09-09
 

hi all,

I have a issue in filtering product using attribute set. I have create one attribute “filter_by” and add options like “red, blue, $1000, $1500” etc etc. this attribute is multi select combo

my requirement is like that i want to show category list and when someone click on category it will open sub menu with all option i have added for filter_by attribute.

for example, i have a category say “Cloth” so when someone click on “cloth” it will open submenu with “red, blue, $1000, $1500” option. now when user click on “red” it will display all cloth in which i have set “filter_by” as red.

see attach image to know visual representation of my issue

can anyone suggests which parameter i have to pass in URL of this option submenu so it will populated desired result?

I m using magento 1.1.5 version.

thanks in advance.
Jimmy

Image Attachments
issue.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
lostbens
Member
 
Total Posts:  31
Joined:  2008-09-04
 

you should get this functionality for free, its layered navigation in magento (check the demo store to see it in action)

make sure the attributes are set in “use in layered navigation” to “filterable with results” - in the “manage attributes” menu.

also, you must have products in your catalog using these attributes for these filters to become active.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Creative_Glance
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2008-09-09
 

thanks for ur response

yeah i have set that attribute “use in layered navigation” to “filterable with results”

but

while calling category on sidebar, i am calling attribute option in sidebae.phtml. like

$product Mage::getModel("catalog/product");
    
$attributes Mage::getResourceModel("eav/entity_attribute_collection"
                ->
setEntityTypeFilter($product->getResource()->getTypeId())
                ->
addFieldToFilter("attribute_code""sort_by"// This can be changed to any attribute code 
                
->load(false); 
    
    
$attribute $attributes->getFirstItem()->setEntity($product->getResource()); /* @var $attribute Mage_Eav_Model_Entity_Attribute */ 
    
    
$sortby $attribute->getSource()->getAllOptions(false);
    
?>
<div class="menu">
  <
ul id="main_menu">
      
<?php foreach ($this->getStoreCategories() as $_category): ?>
    <?php
        
if ($this->isCategoryActive($_category)) {
            $str_sort_by    
=    '<ul>';
        
else {
            $str_sort_by    
=    '<ul style="display: none">';
        
}
        
        
foreach($sortby as $sort_attribute{

                      
// here i m getting only "lable" and "value" as array index of $sort_attribute;
                     // i do not get any URL 

            
$str_sort_by    .=    '<li>'.$sort_attribute["label"].'</li>';
        
}
        $str_sort_by    
.=    "</ul>";
    
?>
   <?php 
echo $this->drawItem($_category$str_sort_by?>
    <?php 
endforeach ?>
  
</ul>
  <
div class="leftpart_logo">
      
<?php 
        
echo $this->getLayout()->createBlock('cms/block')->setBlockId('payment_logo')->toHtml() 
    
?>
  
</div>
</
div>

here. i am not getting any URL for this line
‘<li><a href="WHICH_URL">’.$sort_attribute["label"].’</a></li>’;

how can u get that

 
Magento Community Magento Community
Magento Community
Magento Community
 
lostbens
Member
 
Total Posts:  31
Joined:  2008-09-04
 

Hmmm… looks like its set up correctly.

Since you’re duplicating existing magento functionality could you take a look at the category navigation code and see how that’s done?

I haven’t really got into custom coding, you’re ahead of me there, but I can’t see that you’re doing anything which magento doesn’t do so there should be some sample code you can lift. Sorry i can’t help further…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Creative_Glance
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2008-09-09
 

thanks lostbens

anyone else who can help me

 
Magento Community Magento Community
Magento Community
Magento Community
 
Roshan Lal Sharma
Jr. Member
 
Total Posts:  2
Joined:  2008-09-17
 

Hi Please help me urgent?

We need to set up the manufacturer pages on home page so that the products are not just listed, but that any categories that the manufacturers products are in are also displayed.

Thanks & Regards
Roshan Lal Sharma

 
Magento Community Magento Community
Magento Community
Magento Community
 
joyously
Guru
 
Total Posts:  447
Joined:  2008-08-21
 

I think if you get rid of your custom code and let the layered navigation do what it does, you’ll get the result you want. If the attribute is “filterable with results” it will only show if there are products with that attribute value. If you set it to “filterable with no results” then it will always show even if there are no products with that attribute value.
Also, I read some people were having problems with the multiple select attributes and layered navigation. Search the forum for more info on that.

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