Magento: get all customers from the group

As the title says, I need all users to be assigned to a specific group.

In magento, I created a group of clients called "clients" with ID 4.

Now I need to list all the users of this group outside magento using a custom script, and I can not find a solution.

with this small code, I can get ALL registered registered users, do you know how I can filter this to get only clients in group 4 ID?

$collection = Mage::getModel('customer/customer') ->getCollection() ->addAttributeToSelect('*'); $result = array(); foreach ($collection as $customer) { $result[] = $customer->toArray(); } 

Thanks!

+4
source share
2 answers

You can easily add a filter to the collection to return all customers from a specific group.

 $collection = Mage::getModel('customer/customer') ->getCollection() ->addAttributeToSelect('*') ->addFieldToFilter('group_id', 4); 
+17
source

I think you should add: -> addFieldToFilter ('customer_group_id', '1');

+1
source

All Articles