I am trying to figure out how to get an attribute code from a filter list in Magento.
<?php
$_filters = $this->getFilters();
foreach ($_filters as $_filter)
{
echo $this->__($_filter->getName());
echo $this->__($_filter->getAttributeCode()); # color_name
}
?>
getAttributeCode() isnt a method.
I want to specify a CSS classname for each filter to the attribute_code in app/design/frontend/default/default/template/catalog/layer/view.phtml
The following will work:
The key here is to check that the filter is actually an attribute as some aren’t (most commonly categories) and these types of filters obviously won’t have an attribute code.