3

I need to use the customer group name in the invoice. Based on $order I can get the customer group ID.

$customerGroupId = $order->getCustomerGroupId();

I tried the following code:

$groupname = Mage::getModel(‘customer/customer_group’)->load($customerGroupId);

This results in the following error:

Fatal error: Call to a member function load() on a non-object

How can I get the group name?

  • Which Magento Version are you even using? – Black Jul 6 '18 at 12:07
9

The object I think you are looking for is Mage_Customer_Model_Group so you will need to update your load to use the following.

$groupname = Mage::getModel('customer/group')->load($customerGroupId)->getCustomerGroupCode();

On another note there is no name on customer groups but instead 'customer_group_code'. With the default data that comes with Magento the codes look as follows.

NOT LOGGED IN, General...etc

To get the code you can either call getCustomerGroupCode or there is a function getCode which is simply an alias for the first one.

  • That's quick! Can't accept the answer right now (have to wait 10 minutes), but will do so later! – SPRBRN Apr 29 '14 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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