Multiple calls to $model->save() in Magento over-writing data
Ah, it seems like I may have answered my own question. By including a call to $requestModel->unsetData();
just after the call to $requestModel->save()
the loop works as intended.
unsetData
is a method made available by Varien_Object, which Mage_Core_Model_Abstract inherits from.
I'm happy for someone to contribute a more elegant solution I'm happy to hear it.
When Magento saves a new object it automatically generates an id for the object. After you have saved the object hence an id is generated. To make magento recognize your data as a new model again, you simply need to unset the model id
. I think however unsetData
is more elegant as it also erases any data that might have been created for the previous object :-).