Customer Groups in Magento

Hello All,

I am writing here a script for displaying a select box of customers group.

There exists a Helper file for Customer at app/code/core/Mage/Customer/Helper/Data.php .

We need to extend this class for using the default function

Create a sample module inside local

I have used the Namespace ‘Decryptweb’ for my custom module.

For custom module you need to add a file in etc/modules/Decryptweb_Customer.xml

The content will be

<?xml version="1.0"?>









So your helper will be app/local/Decryptweb/Customer/Helper/Data.php

Paste this content inside it


class Decryptweb_Customer_Helper_Data extends Mage_Customer_Helper_Data


	public function getGroupsHtml()


		$opt = array('value' => '','label' => 'Please Select Group');					       			

		$options = $this->getGroups()->toOptionArray();	




			$select_options = $options;  	            	



			$select_options = $opt;


		$select = Mage::app()->getLayout()->createBlock('core/html_select')





        return $select->getHtml();




Now for displaying the select box in any view file
use the below script


    $custmer_helper = new Decryptweb_Customer_Helper_Data;

    $select_box	= $custmer_helper->getGroupsHtml(); //get customers group

    echo $select_box;


For knowledge of select box you can check this post Select Box In Magento

Hope its helpful

4 thoughts on “Customer Groups in Magento

  1. Hi,

    Good post. I buy use this select box to register form.

    Its’s posible?

    Thanks, greats!

    1. @Miguel – Yes you can display the select box of customer groups in any view file

      Buy using this code

          $custmer_helper = new Decryptweb_Customer_Helper_Data;
          $select_box = $custmer_helper->getGroupsHtml(); //get customers group
          echo $select_box;

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top