如何在产品视图页面中显示类别自定义设计布局? [英] How to display category custom design layout in product view page?

查看:13
本文介绍了如何在产品视图页面中显示类别自定义设计布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个类别,A 和 B.

我将 A 设置为在目录上使用layout_a" -> 目录类别 -> 单击一个类别 -> 单击自定义设计选项卡

我将 B 设置为在目录上使用layout_b" -> 目录类别 -> 单击类别 -> 单击自定义设计选项卡

当我访问类别 A 和 B 时,他们会使用我在管理面板上设置的自己的布局来展示产品.当我点击产品列表页面上的一个项目时,产品视图页面不使用自定义设计.

如何强制产品查看页面使用其类别的自定义设计?

解决方案

我自己找到了答案.

  1. 打开产品控制器位于/app/code/Mage/Catalog/controllers/ProductController.php

  2. 添加以下代码到_initProductLayout方法

    $update->addHandle('CATEGORY_'.$product->getCategoryId());

  3. 打开目录布局xml位于/app/design/frontend/default/default/layout/catalog.xml

  4. 添加

<块引用>

<引用名称=root"><action method="setTemplate"><template>您的模板在此</template></action></参考></CATEGORY_您的类别 ID">

Let's say I have two categegories, A and B.

I set A to use 'layout_a' on Catalog -> Catalog Categories -> Click a category -> click custom design tab

I set B to use 'layout_b' on Catalog -> Catalog Categories -> Click a category -> click custom design tab

When I visit category A and B, theydisplays products using their own layout that I set on the admin panel. When I click an item on the product listing page, product view page does not use custom design.

How do I enforce product view page to use its category's custom design?

解决方案

I found the answer by myself.

  1. Open product controller located in /app/code/Mage/Catalog/controllers/ProductController.php

  2. add the following code into _initProductLayout method

    $update->addHandle('CATEGORY_'.$product->getCategoryId());

  3. Open catalog layout xml located in /app/design/frontend/default/default/layout/catalog.xml

  4. add

<CATEGORY_"your category id">
    <reference name="root">
  <action method="setTemplate"><template>yourtemplate here</template></action>
    </reference>
</CATEGORY_"your category id">

这篇关于如何在产品视图页面中显示类别自定义设计布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆