duanjing9739 2012-04-06 21:24
浏览 26
已采纳

magento客户/客户返回错误的值

I'm trying to import a bunch of customer information from Magento into an external application. The external application already knows their entity_ids, and I basically want to get their customer objects and modify some entries.

Here's the code (Thank you StackOverflow for helping me get set up!)

$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());
}

Heres the output. Entities 38, 48, 131 have "Forum Username" empty (which is a custom field):

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"

Yet the last value returned is repeated.

I have checked:

  • just returning forum_username entries for 38, 48, 131 returns NULL as expected.

What might be going wrong?

  • 写回答

1条回答 默认 最新

  • drk49438 2012-04-09 13:44
    关注

    Solved it. I needed to load the customer object inside the loop!

    /* 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());
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案