Magento get customer group Id and group name
Posted on: December 2, 2010 /
Categories: Magento
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();
This does not work when placing an order through the admin.
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();
Post needs to be updated with what tthoeye said.
Is there a way to update the customer group name using php and this kind of code above?
@tthoeye is right. For Magneto 1.9.2 also, following worked.
$group = Mage::getModel(‘customer/group’)->load($groupId);
$group->getCode();
Thanks @tthoeye