Magento: Get Customer Groups
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:
1 2 3 4 5 6 | $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:
1 | print_r($customerGroups); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 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.





Mukesh Chapagain is a graduate of Kathmandu University (Dhulikhel, Nepal) from where he holds a Masters degree in Computer Engineering. Mukesh is a passionate web developer who has keen interest in open source technologies, programming & blogging.