Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save evgv/bdd418fd826d8bf07bff0fdb059d0bdd to your computer and use it in GitHub Desktop.
Save evgv/bdd418fd826d8bf07bff0fdb059d0bdd to your computer and use it in GitHub Desktop.
Mage. Set custom layout by customer group.
  protected $_customer_groups = array('NOT_LOGGED_IN', 'Genaral', 'Wholesale', 'Retail');

    /**
     * Get current customer group and update handle depend from current group
     * Observe event "controller_action_layout_load_before"
     * 
     * @param Varien_Event_Observer $observer
     */
    public function setTemplate(Varien_Event_Observer $observer) 
    {
        $group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();

        $observer->getEvent()->getLayout()->getUpdate()
           ->addHandle('CUSTOMER_GROUP_' . $this->_customer_groups[(int)$group_id]);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment