1

たくさんの顧客情報をMagentoから外部アプリケーションにインポートしようとしています。外部アプリケーションはすでにentity_idsを知っているので、基本的に顧客オブジェクトを取得していくつかのエントリを変更したいと思います。

これがコードです(セットアップを手伝ってくれてありがとう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"

ただし、最後に返された値が繰り返されます。

確認しました:

  • 38、48、131のforum_usernameエントリを返すだけで、期待どおりにNULLが返されます。

何がうまくいかないのでしょうか?

4

1 に答える 1

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());
}
于 2012-04-09T13:44:07.113 に答える