Like said on title, i need to get all the users assigned to a specific group.
In magento, i've created a customer group named "customers" with ID 4.
Now i need to list all the users in this group outside magento with a custom script, and i can't find a solution.
with this little code i can get ALL registered users, do you know how i can filter this to get only customers in group ID 4?
$collection = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('*');
$result = array();
foreach ($collection as $customer) {
$result[] = $customer->toArray();
}
Thank you!
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);
I think you should add: ->addFieldToFilter('customer_group_id','1');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With