如何将属性值作为列表添加到Magento中的页脚?

如何将属性值作为列表添加到Magento中的页脚?,magento,attributes,footer,advanced-search,Magento,Attributes,Footer,Advanced Search,我在Magento的产品具有品牌属性。我需要做的是在页脚显示一个品牌列表。比如:我们的品牌:品牌1,品牌2,品牌3 据我所知,我需要以某种方式从高级搜索中检索值,并将它们作为列表显示在页脚中,但我不知道如何做到这一点。有人对此有解决办法吗?有几个步骤要遵循 这里我给出了如何在页脚添加自定义属性的详细说明 1。您必须在块上创建,以获得所有品牌产品,并指定自定义属性 对于block $attributes = Mage::getSingleton('eav/config') ->get

我在Magento的产品具有品牌属性。我需要做的是在页脚显示一个品牌列表。比如:我们的品牌:品牌1,品牌2,品牌3


据我所知,我需要以某种方式从高级搜索中检索值,并将它们作为列表显示在页脚中,但我不知道如何做到这一点。有人对此有解决办法吗?

有几个步骤要遵循

这里我给出了如何在页脚添加自定义属性的详细说明

1。您必须在块上创建,以获得所有品牌产品,并指定自定义属性

对于block

$attributes = Mage::getSingleton('eav/config')
    ->getEntityType(Mage_Catalog_Model_Product::ENTITY) // pass your attribute id
    ->getAttributeCollection()
    ->addSetInfo();

foreach ($attributes as $attribute)
{
    if ($attribute->usesSource())
    {
        echo "{$attribute->getFrontendLabel()}:\n";
        foreach ($attribute->getSource()->getAllOptions() as $option)
        {
            echo "  {$option['label']}\n";
        }
        echo "\n";
    }
}
上面是打印逻辑,您应该将其存储为一个数组,并返回一个变量

2.在主题中创建视图文件,用于显示,并在主图标文件中调用该块函数

<?php $_brandsCollection = $this->getBrandsLogoCollection();?>
<div class="block block-layered-nav">
<div class="block-title">
    <strong><span><?php echo $this->__('Brands') ?></span></strong>
</div>
 <div class="block-content" > 
          <div id="Carousel2" class="carousel">
                <div class="button navButton previous" style="display:none;">Back</div>
                <div class="button navButton next" style="display:none;">More</div>
                <div class="container">
                    <div class="items">
                    <?php foreach ($_brandsCollection as $_brand): ?>                    
                        <div class="item">
                            <div class="key caption"></div>
                            <div class="icon">
                                                        <img class="brand-base-logo" alt="<?php echo $_brand->getBrandLogo() ?>" src="<?php echo $_brand->getBrandLogo(); ?>" width="50" height="50">            
                            </div>                    
                            <div class="picture">
                            </div>
                        </div>                            
                        <?php endforeach; ?>
                    </div>
                </div>
            </div>
        </div> <!-- end block content-->            
</div> 


返回
更多
getBrandLogo();?>“width=“50”height=“50”>
3。使用您的_layout.xml并在页脚之前引用,将该文件分配给页脚

<reference name="footer">
       <block type="brand/left" name="brands_logolist" before="-" template="brand/home_logo.phtml" />
  </reference>


希望你能理解我的逻辑。

你好,Liyakat!谢谢你的回答,但这并不是我想要的。我不希望产品出现在页脚上,也没有我品牌的徽标。我想要的是显示“产品属性-品牌”“。我已将其作为multiselect进行高级搜索。我所需要的只是这些来自高级搜索的值作为列表显示在页脚中。我不需要搜索结果(不是产品),而是品牌名称,以便用户可以单击品牌名称,它将带他进入包含所有具有此品牌属性的产品的页面。是的,只需尝试上面的块,您将在controller just debug中获得品牌名称that@Artur克拉森,很高兴帮助你。请你投票给我的答案,这样一些人可以信任和利用,如果为未来的参考。