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.
Open product controller located in /app/code/Mage/Catalog/controllers/ProductController.php
add the following code into _initProductLayout method
$update->addHandle(‘CATEGORY_’.$product->getCategoryId());
Open catalog layout xml located in /app/design/frontend/default/default/layout/catalog.xml
add