Gökhan YILDIZ
Gökhan YILDIZ

Reputation: 141

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?

Upvotes: 1

Views: 259

Answers (2)

Gökhan YILDIZ
Gökhan YILDIZ

Reputation: 141

view.php

public function getAllManu()
{
  $product = Mage::getModel('catalog/product');
  $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
              ->setEntityTypeFilter($product->getResource()->getTypeId())
              ->addFieldToFilter('attribute_code', 'product_properties');
  $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
  $product_properties = $attribute->getSource()->getAllOptions(false);
  return $product_properties;
  
  
}

view.phtml

<select class="form-control" onchange="if (this.value) window.location.href=this.value">
                <option>Select</option>
                <?php foreach ($this->getAllManu() as $product_properties): ?>
                <option value="<?php Mage::getURL() ?>catalogsearch/advanced/result/?product_properties[]=<?php echo $product_properties['value'] ?>"><?php echo $product_properties['label'] ?></option>
                <?php endforeach; ?>
            </select>

Upvotes: 1

Amit Bera
Amit Bera

Reputation: 7611

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

Upvotes: 1

Related Questions