类别视图页面的 magento 属性列表

问题描述 投票:0回答:2

我正在尝试列出属性catalog/category/view.phtml文件

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

如何实现此功能?

php magento attributes
2个回答
1
投票

首先获取当前图层集合的get list属性

$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();
            }
        }

希望我能工作


1
投票

视图.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;
  
  
}

查看.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>
© www.soinside.com 2019 - 2024. All rights reserved.