How to show all attribute after layered navigation filter in Magento

How to show all attribute after layered navigation filter in Magento

April 10, 2015 Magento Layered Navigation is really good for filter the product but problem is that, if we select any attribute like color or price all other attribute hide which are not related to selected attribute. To show all the attribute after filter please use the below code. In your frontend theme catalog/template/catalog/layer/filter.phtml replace content with below code:
<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 below line:
<?php echo $this->getStateHtml() ?>
In app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Layer/Filter/Attribute.php find the function applyFilterToCollection and 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 below 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; } }Look like all this big task to do but once you complete above you will see the magic.Happy Coding :)

Related Posts

from my blog


How To Reset Admin Password in Magento

January 20, 2017

As an ecommerce website developer or magento website developer, sometime we  get the a situation when we forget the magento website admin access detail. To reset the password of any...

How to fix layered navigation filer URL in Magento?

April 2, 2015

Magento is really good eCommerce CMS in terms of functionality. Layered Navigation is really good feature of Magento to filter the product in frontend side. Only problem with the layered navigation filter...

Why Hire an OpenCart Developer?

February 3, 2015

OpenCart – the platform of choice for top Online Stores and E-Commerce Portals Why OpenCart? Open Source Platform that is free Great Community Support SEO Friendly Extensive Documentation Support and...