I've added a new column to an existing custom extension table via phpMyAdmin.

I then added the below to the form block and that's working fine:

    $fieldset->addField('exchange_rate_deposit', 'text', array(
        'label'     => 'Exchange Rate (Deposit)',            
        'name'      => 'exchange_rate_deposit',

And was able to get the field to save to the db via:

    $data = $this->getRequest()->getPost();
    $model= Mage::getModel('custom/module')->load($data['id']);
    $model->addData(array('exchange_rate_deposit' => $data['exchange_rate_deposit'])->save());

So after doing that I needed to add a few more columns to the table, so I just duplicated the process, changing the field names etc (I added the columns to the table last) however I cannot get the other fields to save to the database and have no idea why!

Never done this before so not sure exactly what steps you're supposed to take, but it's as if the ORM mappings haven't been setup for the other attributes and it's just ignoring them, and unfortunately I don't really know how I got the original attribute saving to the db. I've cleared the cache to see if that works but to no avail.



$model->addData(array('exchange_rate_balance' => $data['exchange_rate_balance'])->save());


$model->setData(array('exchange_rate_balance' => $data['exchange_rate_balance']))->save();

Another Way,


Another Way,

$modelData = array(
'exchange_rate_balance' => $data['exchange_rate_balance'],
'another_column' => $data['another_column']

  • Magic! Don't know why $model->setExchangeRateBalance($data['exchange_rate_balance'])->save(); caused all the attributes I'd added to work too without any other changes.. – denton101 Mar 18 '15 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.