2012-04-06 36 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()); 
}