【问题标题】:Magento Show Attributes on list/grid view based on Attribute SetMagento 根据属性集在列表/网格视图上显示属性
【发布时间】:2014-10-06 10:50:08
【问题描述】:

我已按照此处的指南允许基于产品属性集应用布局更新: 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>

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

任何帮助将不胜感激。

【问题讨论】:

    标签: magento attributes


    【解决方案1】:

    肮脏的解决方法....暂时。

    <?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();
                            ?>  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-28
      • 2016-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多