2013-02-28 44 views
0

我用这个代码来选择所有客户的详细信息如何给其中的Magento客户选择代码条件

function getCustomers() { 
    /* Magento's Mage.php path 
    * Mage Enabler users may skip these lines 
    */ 
    require_once ("../mysite/app/Mage.php"); 
    umask(0); 
    Mage::app("default"); 
    /* Magento's Mage.php path */ 
    /* Get customer model, run a query */ 
    $collection = Mage::getModel('customer/customer') 
        ->getCollection() 

        ->addAttributeToSelect('*'); 

    $result = array(); 
    foreach ($collection as $customer) { 
     $result[] = $customer->toArray(); 
    } 
    return $result; 
} 

但我阿洛斯要检查一个字段值...

也就是说THRE有列eav_attribute表“usertypecurrent” .....

我需要检查它的值是0

这意味着选择所有客户的用户类型其为0 ...

我该怎么做?

回答

1

您可以使用addAttributeToFilter基于属性筛选结果值

$collection = Mage::getModel('customer/customer') 
        ->getCollection() 
        ->addAttributeToFilter('usertypecurrent', array('eq' =>0)) 
        ->addAttributeToSelect('*');