phpmagentoattributes

magento attribute list for category view page


i'm trying to list attributes catalog/category/view.phtml file

https://i.sstatic.net/P57vH.jpg

How can i do this feature?


Solution

  • First to get current layer collection the get list attribute

    $CurrentLayer=Mage::getSingleton('catalog/layer');
    
            $attributes = $CurrentLayer->getFilterableAttributes();
    
            foreach ($attributes as $attribute) {
                if ($attribute->getAttributeCode() == 'price') {
                    $filterBlockName = 'catalog/layer_filter_price';
                } elseif ($attribute->getBackendType() == 'decimal') {
                    $filterBlockName = 'catalog/layer_filter_decimal';
                } else {
                    $filterBlockName = 'catalog/layer_filter_attribute';
                }
    
                $result = $this->getLayout()->createBlock($filterBlockName)->setLayer($layer)->setAttributeModel($attribute)->init();
    
                foreach($result->getItems() as $option) {
                    echo $option->getLabel().'<br/>';
                    echo $option->getValue();
                }
            }
    

    Hope i will be working