0

Hi I added custom attribute to bundle product(For Chocolate Box(Yes/No)); I need change product tamplate(for custom tamplate) if "Yes" is active! Help me please!

Controller

class Chocolate_Box_IndexController extends Mage_Core_Controller_Front_Action
{

        public function indexAction()
        {
            $this->loadLayout();
            $this->renderLayout();
        }
}

config.xml

    <layout>
        <updates>
            <chocolatebox>
                <file>chocolatebox.xml</file>
            </chocolatebox>
        </updates>
    </layout>
</frontend>

layout

<PRODUCT_TYPE_bundle>
    <reference name="head">
        <action method="addItem"><type>skin_js</type><name>js/chocolatebox/chocolatebox.js</name></action>
        <action method="addItem"><type>js_css</type><stylesheet>chocolatebox/css/style.css</stylesheet></action>
    </reference>
    <reference name="product.info">
        <action method="setTemplate">
            <template>chocolatebox/chocolatebox.phtml</template>
        </action>
    </reference>
</PRODUCT_TYPE_bundle>

1 Answer 1

1

There are a number of ways. In your case your layout reference is incorrect (should be reference="root").

From the controller:

class Chocolate_Box_IndexController extends Mage_Core_Controller_Front_Action
{
    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('page/1column.phtml');
    }
}

From the layout:

<PRODUCT_TYPE_bundle>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
</PRODUCT_TYPE_bundle>
2
  • It doesn`t help me! I think I need to use _beforeToHtml() method
    – Sergey
    Commented Nov 24, 2014 at 9:29
  • Template should be set in constructor. What other modules do you have installed?
    – philwinkle
    Commented Nov 24, 2014 at 15:48

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.