I am trying to set 2columns-right.phtml layout for products under specific category while the default is 1column.phtml.(Please note i don't want to change Category page layout but layouts of products under that category)

I tried Admin >Manage categories >Select Category >Custom design >Change "Apply to Products" to yes and in "Custom Layout Updates" entered

<reference name="product.info">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>

Didn't work

Then i went to rwd/default/layout/catalog.xml and added after

    Product view


<reference name="product.info">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>

But even this didn't work, It would be of great help any ideas on this. Magento CE Version 1.9.1

  • product can be in multiple categories Commented Feb 23, 2017 at 7:27
  • yes but not in my case Commented Feb 23, 2017 at 7:31

5 Answers 5


Create a small module

Your config.xml should looks like


<?xml version="1.0" encoding="UTF-8"?>

Your observer should looks like


class Package_Extension_Model_Observer

    public function cateHandle(Varien_Event_Observer $observer)
        $product = Mage::registry('current_product');

         * Return if it is not product page
        if (!($product instanceof Mage_Catalog_Model_Product)) {
        $category= 3;
        if(in_array($category, $categories)){
            $update = $observer->getEvent()->getLayout()->getUpdate();


And in your themes local.xml add below code or as you mention rwd/default/layout/catalog.xml add below code

    <reference name="root">
      <action method="setTemplate"><template>page/2columns-right.phtml</template></action>

Use controller_action_layout_generate_xml_before Event



public function changeTemplate($observer)
    $action = $observer->getEvent()->getAction();
    $fullActionName = $action->getFullActionName();
    $category=<YOUR CATEGORY ID>;


      if(in_array($category, $categories);){
        $layout = $observer->getEvent()->getLayout();
        $update = $layout->getUpdate();
        $xml = "<reference name='root'><action method='setTemplate'><template>page/2columns-right.phtml</template></action></reference>";

You can set layout for any specific category as per your requirement from admin.

Follow the steps:

Login to admin >> catalog >> Manage categories >> select your category >> custom design tab >> change page layout >> save category.


The following setting should work:

Go to Admin >Manage categories >Select Category >Custom design then select

  1. Page Layout to 2columns-right.phtml and
  2. In Custom Layout Update put the following code.

    <reference name="product.info">
      //put the child block here that you want call.

Found a much simpler solution, if you only need the change for a couple of products:

create a fancy_name.phtml file in your_theme/default/template/page/ (from copy of 1column-product.phtml or something).

Edit fancy_name.phtml until it becomes really fancy.

Go to magento backend, go to your product, go to design -> Custom layout update. Paste the following code and save:

<reference name="root">
    <action method="setTemplate"><template>page/fancy_name.phtml</template></action>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.