6

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

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

| improve this answer | |
  • Zifius what code to use ? I trying this but not working.$customer = Mage::getModel('customer/customer')->load($customerId); $customer->getGroupId() Mage::helper('customer')->getGroups(); Also i need to get custom attributes whatc I create. Order by, Purchase Order Number. How to get these custom attributes ? – Webjuice Feb 16 '15 at 9:33
  • @lew1s please post the code you have so far somewhere like GitHub gist, will be easier to go from there. Also the way you have created your attributes – Zifius Feb 16 '15 at 10:43
  • Using Order Export tool by [link]wyomind.com/orders-export-tool-magento.html . I created two new attributes using Manage Customer Attributes from [link] magentocommerce.com/magento-connect/… which are "account number" and "rep code". With another extension [codecanyon.net/item/magento-order-attributes/8487808] I created Order attributes which are "Purchase number" and "Order by" . So I what to get these fields and show in my xml file.I trying to get the "customer group name" or ID and my custom attr.[link]pastebin.com/KS8qYGux – Webjuice Feb 16 '15 at 10:52
  • here is a documentation of export extension what I am using [link]wyomind.com/orders-export-tool-magento.html – Webjuice Feb 16 '15 at 11:07
  • @lew1s: in which extension you are trying to use the code I posted? it can't just work as is, has to be adapted and since the extension is not open source don't think you can share the code – Zifius Feb 16 '15 at 11:08
1

So the answer is:

For Customer Group Name:

<? return Mage::getModel('customer/group')->load({customer_group_id})->getCustomerGroupCode(); ?>

For two fields in Customer Account Information:

<? return Mage::getModel('customer/customer')->load({customer_id})->getAccountNumber(); ?>

For the two field generated by Custom Order Attributes from CodeCanyon:

<? return Mage::getModel('glaceorderattr/attribute')->load({entity_id}, 'order_id')->getPurchaseOrderNumber(); ?>

I hope it helps somebody. THANKS TO @Zifius

| improve this answer | |

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.