I'm looking for a way to load a template (.phtml) per group. In this case i want to show all options to a logged in user for a bundle product. Other users should be able to see the options but they can not order.

At this moment i am using this code to detect the user group. A user with groupId == 2 will be shown the normal template. But how do i replace the 'Get a different template' text with an actual template? At this moment i am just showing text instead off a template.

            $login = Mage::getSingleton( 'customer/session' )->isLoggedIn(); //Check if User is Logged In
                $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); //Get Customers Group ID
                if($groupId == 2) //2
                echo $this->getChildHtml('', true, true);

            else {
                echo ('Get a different template with name options-new.phtml');

FYI: I placed this code in the wrapper.phtml and i am trying to show bundled options.


You can get child block then set the template:

$optionBlock = $this->getChild('child_block_name');
if($groupID == 2)

echo $optionBlock->toHtml();

My solution is creating a new block like this:

class Example_Module_Block_Grouptemplate extends Mage_Core_Block_Template 
    public function __construct()
        $groupID = 2;
        if(Mage::getSingleton('customer/session')->isLoggedIn() && Mage::getSingleton('customer/session')->getCustomerGroupId() == $groupID){
        } else {


And change the layout to use new block:

<block type="examplemodule/grouptemplate" name="options" />


  • you should change the parent class name and block name to matching with your current code.
  • Use the group name ore create new attribute for customer group instead of hardcode id = 2 ;
  • Thank you for answering. One small question is: where do you create the new block (what file)? – matthijshofstede Oct 8 '14 at 8:22
  • Seem like you're not a magento developer, you should google to learn more about how to create Magento module. – Minh Tran Oct 9 '14 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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