Magento基于属性集在列表/网格视图上显示属性

时间:2014-10-06 10:50:08

标签: magento attributes

我已遵循此处的指南,允许根据产品属性集应用布局更新: http://magebase.com/magento-tutorials/creating-custom-layout-handles/

理想情况下,我希望根据属性集在列表和网格视图的目录类别页面上显示某些属性。

所以我在local.xml中添加了这个

    <!-- CATALOG LIST / GRID -->
    <PRODUCT_ATTRIBUTE_SET_Antibodies>
        <reference name="extra.product.detail.list">
            <block type="core/template" name="antibody.detail.extra" template="catalog/product/list/detail/antibodies.phtml" />  
        </reference>
    </PRODUCT_ATTRIBUTE_SET_Antibodies> 

以下是对extra.product.detail.list(精简版)

的引用
<catalog_category_layered translate="label">
    <label>Catalog Category (Anchor)</label>
    <reference name="root">
        <action method="setTemplate"><template>page/2columns-left-flipped.phtml</template></action>
    </reference>            
    <reference name="left">
        <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
    </reference>
    <reference name="content">
        <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
            <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">

                <!-- ADDED THIS -->
                <block type="core/text_list" name="extra.product.detail.list" as="extra_product_detail_list" />

            </block>
        </block>
    </reference>
</catalog_category_layered>

我似乎无法在类别页面上显示任何内容?该布局更新仅适用于产品页面吗?

任何帮助都将深表感谢。

1 个答案:

答案 0 :(得分:0)

肮脏的解决方法....现在。

<?php $attributeSetId = $_product->getAttributeSetId(); ?>
<?php 
$attributeSetDetailTemplate = false;
switch($attributeSetId):
    case 9: // Antibodies
        $attributeSetDetailTemplate = 'antibodies';
    break;
endswitch;
if($attributeSetDetailTemplate) echo $this->getLayout()->createBlock('catalog/product_list')->setTemplate('catalog/product/list/detail/'.$attributeSetDetailTemplate.'.phtml')->setProductId($_product->getId())->toHtml();
                        ?>  
相关问题