This article shows how to get all customer groups name and id in Magento 1.
To get all customer groups, we will be using Mage_Customer_Model_Resource_Group_Collection
class.
Here’s the code:
$collection = Mage::getResourceModel('customer/group_collection');
$customerGroups = $collection->toOptionArray();
// adding a new element to the beginning of customerGroups array
array_unshift($customerGroups, array('value'=>'', 'label'=>'Any'));
Sample Output:
print_r($customerGroups);
Array
(
[0] => Array
(
[value] =>
[label] => Any
)
[1] => Array
(
[value] => 0
[label] => NOT LOGGED IN
)
[2] => Array
(
[value] => 1
[label] => General
)
[3] => Array
(
[value] => 2
[label] => Wholesale
)
[4] => Array
(
[value] => 3
[label] => Retailer
)
)
Hope this helps. Thanks.