如何在产品查看页面中显示类别自定义设计布局? [英] How to display category custom design layout in product view page?
问题描述
假设我有两个类别,A和B.
Let's say I have two categegories, A and B.
我在目录->目录类别->单击类别->单击自定义设计选项卡上将A设置为使用'layout_a'
I set A to use 'layout_a' on Catalog -> Catalog Categories -> Click a category -> click custom design tab
我在目录->目录类别->单击类别->单击自定义设计选项卡上将B设置为使用'layout_b'
I set B to use 'layout_b' on Catalog -> Catalog Categories -> Click a category -> click custom design tab
当我访问类别A和类别B时,它们会使用我在管理面板上设置的自己的布局来显示产品.当我单击产品列表页面上的项目时,产品视图页面未使用自定义设计.
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?
推荐答案
我自己找到了答案.
-
位于/app/code/Mage/Catalog/controllers/ProductController.php中的
-
打开产品控制器
Open product controller located in /app/code/Mage/Catalog/controllers/ProductController.php
添加到_initProductLayout方法
add the following code into _initProductLayout method
$ update-> addHandle('CATEGORY _'.$ product-> getCategoryId());
$update->addHandle('CATEGORY_'.$product->getCategoryId());
打开目录布局xml
添加
<CATEGORY_"your category id">
<reference name="root">
<action method="setTemplate"><template>yourtemplate here</template></action>
</reference>
</CATEGORY_"your category id">
这篇关于如何在产品查看页面中显示类别自定义设计布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!