2

Can anyone help me to get all available customer groups?

I want to find customer group names and their ids.

2 Answers 2

9

You can use below mentioned code run it from your magento dir:

<?php 
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('admin'); 
$customer = Mage::getModel('customer/group')->getCollection();
foreach($customer as $type) {
    echo '<pre>Customer group id :'.$type->getCustomerGroupId().'<br>';
    echo '<pre>Customer group code :'.$type->getCustomerGroupCode().'<br>';

   }
?>
0
3

Use following function

$groups = Mage::getModel('customer/group')->getCollection();
foreach ($groups as $Group) {

  echo 'Customer GroupID = '.$Group->getCustomerGroupId().'<br>';
  echo 'Customer Group Name = '.$Group->getCustomerGroupCode().'<br>';

}

Hope this will help you

2
  • Yes I have tried that but I am not getting how to get all customer group names and ids from it?
    – vedu
    Commented Mar 3, 2016 at 6:47
  • Modified my answer check it Commented Mar 3, 2016 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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