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

Page 1 of 3
Show all attributes after filter in layered navigation
 
Anjanesh
Sr. Member
 
Avatar
Total Posts:  136
Joined:  2008-03-15
Mumbai, India
 

I have Shop By Color in my Layered Navigation and shows all the colors on the left column.
But on selecting a color, the colors dont show since its filtered by a specific color.
Is there a way to display all the colors after filter ?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ben Marks
Guru
 
Avatar
Total Posts:  452
Joined:  2008-10-09
Charleston, SC
 

Take a look in catalog/layer/view.phtml and eliminate the canShowOptions check.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Anjanesh
Sr. Member
 
Avatar
Total Posts:  136
Joined:  2008-03-15
Mumbai, India
 

Tried that - doesnt work.

<?php $_filters $this->getFilters() ?>
<?php 
foreach ($_filters as $_filter): ?>
<?php 
echo $_filter->getHtml() ?> <!-- Purposely added to force show filter html -->
will still not show the color options.

$_filters = $this->getFilters()
doesnt include the selected options

 
Magento Community Magento Community
Magento Community
Magento Community
 
doctorlogos
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-05-06
 

Wow this is what I need.

For me, Magento’s layered navigation is a very poor weak.. I’ve done tests with friends and most of them (normal users) didn’t know quickly where the other colors were (they didn’t realize that it’s necessary clear the selection and select again other color).

I also don’t want to hide the attributes list when I select one.

 
Magento Community Magento Community
Magento Community
Magento Community
 
klistrian
Member
 
Total Posts:  42
Joined:  2009-06-19
 

I would really like this as well. Just keep all attributes as in the first non-filtered view except that the selected attribute now is highlighted.

Does anyone have any pointers on how I can retrieve all attributes so they can be used in the filtered view? I’ll happily code it and post the solution here but I’m stuck right now.

 
Magento Community Magento Community
Magento Community
Magento Community
 
klistrian
Member
 
Total Posts:  42
Joined:  2009-06-19
 

Amasty, how about you stop continuously spamming this forum. If you want to be a part of the community, contribute with code or knowledge. Your extension doesn’t even solve the discussed problem.

To get back on track, what i want and what I think Anjanesh wants:
After I have selected, for instance, the color yellow, what I want is this view:

brown (6)
yellow (4) (x)
green (7)

Then I should be able to click on, for instance, green and get this view:

brown (6)
yellow (4)
green (7) (x)

I don’t want checkboxes as I only want the user to be able to select one item per attribute. Clicking an other color, cancels the previous attribute and clicking the (x) brings it back to no color selected.

If anybody has any code, idea or wild guess on how to retrieve these filter values from state.phtml then please contribute (or any other method). Do not post spam for your extensions.

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

Hello klistrian, I appreciate your opinion and I really want to help. 

The module, by the way HAS feature to single select attributes without removing the other, so please don’t provide wrong information, thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
klistrian
Member
 
Total Posts:  42
Joined:  2009-06-19
 

Amasty, thanks for trying to actually contribute but no one here has asked how to remove the quantity figure. I suggest you read the thread again.

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

Hello, sorry for my mistake, have already fixed it, it was a post to http://www.magentocommerce.com/boards/viewreply/310983/.

Back to the current issue, we need 2 things:
1) get the current selection, it is easy to do checking the request variable
2) show all list of attributes, it is a bit more tricky and requires editing/rewriting Mage_Catalog_Model_Layer_Filter_Attribute class.

 
Magento Community Magento Community
Magento Community
Magento Community
 
klistrian
Member
 
Total Posts:  42
Joined:  2009-06-19
 

I did it! Took a few days of fighting with the magento core but now it’s there, exactly how I wanted it. Me so happy.

You can see the result at http://www.tieroom.com/neckties/ties.

So how did I do it? Well, hacked a couple of templates and then messed up some magento core code. Obviously, you should not change magento core code but if you want a quick fix.... I might extract my solution into a zip or extension that does the changes properly under community etc.

Feel free to comment my code and propose better solutions. I’m defnitely not claiming to have coded the fanciest solution, just a dirty and quick but working one.

My solution completely changes the look & feel from the standard layered navigation and it has some fugly inline CSS so you will probably want to apply your own css before kicking this out to production.

In your frontend theme catalog /template/catalog/layer, replace the content of filter.phtml with:

<ol>
<?php 
 $selection 
FALSE
 
$items $this->getItems();
 foreach (
$this->getItems() as $_item)
   
{
      
if ($_item->isSelected())
           
{
       $selection 
TRUE
       
$removal_url=$_item->getRemoveUrl();
       break;
         
}
   }
?>
<li>
<?php if ($selection): ?>
<a style="margin-top:2px; color: #666633" class="multi-select unselected" href="<?php echo $removal_url ?>"><?php echo $this->__('Show all'?></a>
<?php else: ?>
<img style="margin-top:2px;" src="<?php echo $this->getSkinUrl('images/narrow_by_li_by.gif'); ?>"> <a style="color: #D96708" class="multi-select isselected" href="<?php echo $this->urlEscape($_item->getRemoveUrl()) ?>"><?php echo $this->__('Show all'?></a>
<?php endif ?>
</li>   
<?php foreach ($this->getItems() as $_item): ?>
    
<li>
            
<?php if( $_item->isSelected() ) : ?>

              
<img src="<?php echo $this->getSkinUrl('images/narrow_by_li_by.gif'); ?>"> <a style="color: #D96708" class="multi-select isselected" href="<?php echo $removal_url ?>"><?php echo $_item->getLabel() ?></a>
            
<?php else : ?>
              
<a style="color: #666633" class="multi-select unselected" href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
            
<?php endif; ?>
    
</li>
<?php endforeach ?>

</ol>

In view.phtml, just comment out or delete the following line:

<?php echo $this->getStateHtml() ?>
In function applyFilterToCollection in app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Layer/Filter/Attribute.php
Replace:
$tableAlias $attribute->getAttributeCode() . '_idx';
With:
$tableAlias $attribute->getAttributeCode() . '_idx_'.$value;

In apply in app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php, comment out or delete the following line:

$this->_items = array();
And replace the following in _getItemsData:
if ($this->_getIsFilterableAttribute($attribute) == self::OPTIONS_ONLY_WITH_RESULTS)
with:
if (($this->_getIsFilterableAttribute($attribute) == self::OPTIONS_ONLY_WITH_RESULTS) && (!empty($optionsCount[$option['value']])))

Add the following method to app/code/core/Mage/Catalog/Model/Layer/Filter/Item.php:

public function isSelected()
    
{
      $selected 
Mage::getSingleton('core/app')->getRequest()->getParam($this->getFilter()->getRequestVar());
    
      if( 
$selected == $this->getValue() )
    
{
          
return true;
        
}
      
else
        
{      
            
return false;
    
}
    }
 
Magento Community Magento Community
Magento Community
Magento Community
 
marog
Jr. Member
 
Total Posts:  16
Joined:  2010-05-19
 

Just want to say thank you! That helped me a lot.

 
Magento Community Magento Community
Magento Community
Magento Community
 
demonkoryu
Guru
 
Avatar
Total Posts:  328
Joined:  2008-11-26
Dortmund, Germany
 

klistrian, thanks! You’ve saved me hours. And your solution is quite elegant.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bgthw
Jr. Member
 
Total Posts:  4
Joined:  2010-05-16
 

Hello,

very nice, Thanks !!

Is it possible to have the same result for category layered, I\’m looking for something to modify but I have not the solution now…

Maybe You ?  smile

BGTHW.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nickwanhere
Jr. Member
 
Total Posts:  3
Joined:  2010-05-13
 

I love you klistrian!

Save my day!

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzvikr
Jr. Member
 
Total Posts:  8
Joined:  2011-03-18
 

Hi

has anyone tried this on 1.5.0.1 ?

thanks,
-Tzvi

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzvikr
Jr. Member
 
Total Posts:  8
Joined:  2011-03-18
 

it works on 1.5

i cant make it work on price and category , any ideas ?

-Tzvi

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 3