Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento get attribute code from filter.phtml

Tags:

php

magento

I am trying to get the attribute code from the filter.phtml template file. Does anyone have any ideas how to do this?

like image 846
Chad Avatar asked Nov 28 '22 18:11

Chad


2 Answers

$_item->getFilter()->getAttributeModel()->getAttributeCode()

The above line of code can be used to get the attribute code when it is in the loop.

like image 197
Darren Avatar answered Dec 05 '22 16:12

Darren


It will works only if filter is attribute bu for category it will not work so you have to write like

echo $_filter->getType();
if($_filter->getType()=='catalog/layer_filter_attribute')
{
    echo $_filter->getAttributeModel()->getAttributeCode();
}
like image 23
Abhijit Avatar answered Dec 05 '22 15:12

Abhijit