Get Magento Customer Group ID and Name from Admin Side

adminmagento-1.7PHP

I need a script to show from admin side and export in XML Customer Group ID and Group Name.

This is the code to show Customer Group ID on front-end. But this is not working in back-end:

$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();

Best Answer

You need to load the customer model by the customer id, e.g.:

$customer = Mage::getModel('customer/customer')->load($customerId);

Then based on the customer model you can get the group id with $customer->getGroupId()

Mage::helper('customer')->getGroups() returns a list of groups excluding non-logged in one, based on it you can determine customer_group_code which will be the customer assigned group name

Related Topic