代码之家  ›  专栏  ›  技术社区  ›  Castro Roy

保存客户以前的数据

  •  1
  • Castro Roy  · 技术社区  · 15 年前

    我为客户制作了一个带有计算器的页面,他们不需要登录就可以使用它,该页面上有一个保存按钮,我想做的是:如果客户单击保存而没有登录,将被重定向到注册表窗体,如果用户成功注册,我需要将他在计算器中写的数据保存到他的帐户,然后重新重定向到计算器。他给客户添加了新的属性

    $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,
    ));
    

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

    1 回复  |  直到 13 年前
        1
  •  1
  •   Castro Roy    15 年前

    几个小时后,我会回答我自己的问题,如果有人能纠正我,我会很感激。。。
    所以,我做的是:

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

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

    它工作正常…感谢所有读过我文章的人

    推荐文章