doutuo6689 2010-08-16 17:12
浏览 14
已采纳

保存客户以前的数据

i've made a page with a calculator for customer, they can use it without being logged in, there is a save button in that page, what i'm trying to do is: if a customer click save and it is not logged in, will be redirect to the register form, and if the user successfully register, i need to save the data he wrote in the calculator to his account and redirect to the calculator again. I'he added the new attributes to the customer

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'weight', array(
    'label'=> 'Weight',
    'type'=> 'decimal',
    'input'=> 'text',
    'visible'=> true,
    'required'=> false,
));
$setup->addAttribute('customer', 'Height', array(
    'label'=> 'Height',
    'type'=> 'decimal',
    'input'=> 'text',
    'visible'=> true,
    'required'=> false,
    'position'=> 1,
));

And if i run this code, it work cuz i can see the value in the database

$session = Mage::getSingleton('customer/session');
$customer = $session->getCustomer();
$customer->setWeight(80);
$customer->save();

But my problem is how i collect all the data of the calculator

  • 写回答

1条回答 默认 最新

  • dsklfsdlkf1232 2010-08-16 19:24
    关注

    after a few hours coding, i'm gonna answer my own question, if someone can correct me i'll be thankfull...
    so, what i did:

    $session = Mage::getSingleton('customer/session');
    if (!$session->isLoggedIn()) {
        $session->setHeight($this->getRequest()->getPost('height'));
    }
    

    now, in the createPostAction i add this

    if(isset($session->getHeight)){
        $customer->setHeight($session->getHeight);
    }
    $session->setHeight('');
    

    it work ok...thanks anyway to everyone who read my qestion

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题