我的产品在Magento有属性品牌。我需要做的是在footer.Something中显示一个品牌列表,比如:我们的品牌:品牌1,品牌2,品牌3。
据我所知,我需要从高级搜索中以某种方式检索值,并以列表的形式在页脚中显示它们,但我不知道如何做到。有谁能解决这个问题吗?
发布于 2013-09-08 05:52:42
有几个步骤要遵循
在这里,我给出了详细的说明如何添加您的自定义属性在页脚。
1.必须在块上创建,才能通过分配自定义属性获得所有品牌产品
为了街区。
$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.在您的主题中创建视图文件以用于显示,并在该home_logo文件中调用该块函数。
<?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> 3.使用页脚前引用的your_layout.xml将该文件分配给页脚。
<reference name="footer">
<block type="brand/left" name="brands_logolist" before="-" template="brand/home_logo.phtml" />
</reference>希望你能理解我的逻辑。
https://stackoverflow.com/questions/18679494
复制相似问题