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 comments

  • tthoeye

    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();

  • Mohit

    @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 *