2010-08-16 21 views
1

我已經爲客戶做了一個計算器頁面,他們可以使用它,而無需登錄,該頁面中有一個保存按鈕,我想要做的是:如果一個客戶點擊保存並且它沒有登錄,將被重定向到註冊表單,並且如果用戶成功註冊,我需要將他在計算器中寫入的數據保存到他的賬戶並再次重定向到計算器。 I'he添加了新的屬性給客戶保存以前的客戶數據

$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

幾個小時後的編碼數據,我要回答我的問題,如果有人可以糾正我,我應該心存感激...
所以,我做了什麼:

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

現在,在createPostAction我反正添加此

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

它的工作確定...感謝大家誰看過我qestion