I used a Layered Navigation SEO to make my layered navigation to have a multiselect on filter and AJAX updater result and layered navigation. Every filter in layered navigation is in Bootstrap 3 collapse. The problem is that when user extend a filter and select something, layered navigation is reloaded by AJAX request and every field is collapsed, witch is annoying.

I want to make some customization on that and add to each filter some unique HTML attribute like data-attribute-code and add some info about witch collapse are extend, so I can set then to be extended when layered navigation is reloaded. Current problem that i have is that i can get only the name of the filter with $_filter->getName() witch is not good to use like identification for filter. But when i try to get a attribute code or id i get empty stings. I try with this code


If someone can help me and show how to get attribute ID or Code i will be very thankful.


2 Answers 2


This will give the attribute code:


You can get attribute id by using the following:

// $attributeCode = YOUR_ATTRIBUTE_CODE; 
// In your case it will be as below:
$attributeCode = $_filter->getRequestVar();

$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')

$attributeId = $attributeInfo->getAttributeId();

Please try this :

 <?php foreach ($_filters as $_filter): ?>
     <?php $attributemode = $_filter->getAttributeModel();
             echo $attributeCode = $attributemode->getAttributeCode();
         } ?>
 <?php endforeach; ?>

This give you attribute code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.