php - Magento:从一组中获取所有客户

标签 php magento

如标题所述,我需要将所有用户分配到特定组。

在 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/

相关文章:

ios - 用于移动应用程序的 Magento REST API OAuth

php - 基于 Woocommerce 中产品类别的条件自定义结帐字段

php - 在退出 apache/xampp 之前运行命令

javascript - 使用 Javascript 将 FORM_1 (page1.html) 的数据传递给 FORM_2 (page.html)

php - 使用 DATE_ADD() 时出现 SQL 语法错误

Magento 合并 javascript 省略文件

mysql - 1.6 中的重新索引错误(indexer.php 中的 PHP 异常)

php - 我如何显示在 Magento 2 中节省的金额?

mysql - 导入 MAGMI 后,Magento Store 变慢了

php - 使用 regexr 工具识别 (weat)her