Magento get customer group Id and group name

Get customer group Id


// Check if costomer is logged in
if(Mage::getSingleton('customer/session')->isLoggedIn())
{
// Get group Id
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
}

Get group name:


$group = Mage::getModel('customer/customer_group')->load($groupId);
$group->getName();

5 responses to “Magento get customer group Id and group name”

  1. I’m using 1.6 and i think it should be

    $group = Mage::getModel(‘customer/group’)->load($groupId);
    $group->getCode();

    instead of

    $group = Mage::getModel(‘customer/customer_group’)->load($groupId);
    $group->getName();

  2. Is there a way to update the customer group name using php and this kind of code above?

  3. @tthoeye is right. For Magneto 1.9.2 also, following worked.

    $group = Mage::getModel(‘customer/group’)->load($groupId);
    $group->getCode();

    Thanks @tthoeye

Leave a Reply

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