如标题所述,我需要将所有用户分配到特定组。
在 magento 中,我创建了一个名为“customers”的客户组,ID 为 4。
现在我需要使用自定义脚本在 magento 之外列出该组中的所有用户,但我找不到解决方案。
用这个小代码我可以获得所有注册用户,你知道我如何过滤它以只获得组 ID 4 中的客户吗?
$collection = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('*');
$result = array();
foreach ($collection as $customer) {
$result[] = $customer->toArray();
}
谢谢!
最佳答案
您可以轻松地向集合添加过滤器以返回特定组中的所有客户。
$collection = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('*')
->addFieldToFilter('group_id', 4);
关于php - Magento:从一组中获取所有客户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14367071/