添加magento中“附加信息”下的属性信息以外的内容

时间:2015-02-23 06:45:40

标签: magento tabs

我们可以在magento产品视图页面中看到“其他信息”标签。

我们可以列出所有属性。

我想在“附加信息”标签下显示一些内容....

装置

主要信息

属性标签1:属性值

子信息

属性标签2:属性值。

如果您需要任何澄清,请告诉我。

提前感谢。

2 个答案:

答案 0 :(得分:0)

正如Magento SE所述:

  

您可以自定义模板   catalog/product/view/attributes.phtml。将其复制到您的主题   base/default如果还没有,请包含您需要的内容。

     

为了更好的可维护性,我建议您添加   $this->getChildHtml('my_child_alias')到模板并定义   布局中的子块(即主题的layout/local.xml

<reference name="product.attributes">
    <block type="core/template" name="my.custom.product.block" as="my_child_alias" template="my/custom/template.phtml" />
</reference>

根据您的评论中的其他信息判断,您可能不想创建子块,而是必须在foreach循环中添加代码。

原始

    <?php foreach ($_additional as $_data): ?>
        <tr>
            <th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
            <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
        </tr>
    <?php endforeach; ?>

已更改(示例)

    <?php foreach ($_additional as $_data): ?>
        <?php if ($_data['code'] == 'attribute_1'): ?>
        <tr><th colspan="2"><?php echo $this->__('Main Information') ?></th></tr>
        <?php elseif ($_data['code'] == 'attribute_2'): ?>
        <tr><th colspan="2"><?php echo $this->__('Sub Information') ?></th></tr>
        <?php endif; ?>
        <tr>
            <th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
            <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
        </tr>
    <?php endforeach; ?>

其中attribute_1attribute_2是每个组的第一个属性的代码。

答案 1 :(得分:0)

修改文件: catalog \ product \ view \ attributes.phtml。

使用此代码替换<th></th>

<th class="label">
<?php if(array_key_exists('size',$_additional) && array_key_exists('color',$_additional) ){
                        if($_data['code'] == 'size'){
                            echo " Main features : ";
                        }
                    } ?>
                    <?php echo $this->escapeHtml($this->__($_data['label'])) ?>
                </th>

应用此代码并结帐。

相关问题