B-219 Sec-55 Noida, India
+918010221733

Get Filterable attribute by Category ID

<?php
$category_ids = $this->getCategoryid(); // HERE YOU CAN PUT THE STATIC CATEGORY ID

$layer = Mage::getModel(“catalog/layer”);
    $categoryid = $category_ids;
    $category = Mage::getModel(“catalog/category”)->load($categoryid);
    $layer->setCurrentCategory($category);
    $attributes = $layer->getFilterableAttributes();

    foreach ($attributes as $attribute) {
        if ($attribute->getAttributeCode() != ‘price’) {
           
            $filterBlockName = ‘catalog/layer_filter_attribute’;
       
        echo ‘<br/>—‘.$attribute->getFrontendLabel();
        echo ‘—<br/>’;
        $result = $this->getLayout()->createBlock($filterBlockName)->setLayer($layer)
->setAttributeModel($attribute)->init();
       
        foreach($result->getItems() as $option) {
            echo $option->getLabel().'<br/>’;
            echo $option->getValue();
        }
        }
}

?>

(Visited 43 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.