views:

39

answers:

1

Hi, 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

A: 

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

Kstro21