2012-04-06 37 views
1

我试图从Magento导入一堆客户信息到外部应用程序中。外部应用程序已经知道他们的entity_ids,我基本上想要获得他们的客户对象并修改一些条目。magento客户/客户返回错误的值

下面的代码(谢谢你的StackOverflow帮我打点一切!)

$collection = Mage::getModel('customer/customer'); 
/* each $key is an entity ID */ 
foreach (array_keys($concatresult) as $key) { 
    $collection->load($key); 
    Zend_Debug::Dump("Key: " . $key . " Forum username:" . $collection->getForumUsername() . " Name: " . $collection->getName()); 
} 

继承人的输出。实体38,48,131 有 “论坛用户名” 空(这是一个自定义字段):

string(53) "Key: 10955 Forum username:user1 Name: F1 L1" 
string(47) "Key: 38 Forum username:user1 Name: F2 L2" 
string(51) "Key: 48 Forum username:user1 Name: F3 L3" 
string(50) "Key: 131 Forum username:user1 Name: F4 L4" 

还没有恢复,重复最后一个值。

我已经检查:

  • 刚刚返回forum_username条目38,48,131返回NULL预期。

什么可能出错?

回答

0

解决了它。我需要在循环中加载客户对象!

/* each $key is an entity ID */ 
foreach (array_keys($concatresult) as $key) { 
    $collection = Mage::getModel('customer/customer'); 
    $collection->load($key); 
    Zend_Debug::Dump("Key: " . $key . " Forum username:" . $collection->getForumUsername() . " Name: " . $collection->getName()); 
}