I'm confused by the way Magento's ORM behaves when editing/saving an object; see the example below:
$model = Mage::getModel('vendor/model')
->setData(array(
'name' => 'Test,
'description' => 'Info',
))
->save();
I now have a new record in the table, however this is where i'm confused.
$model = Mage::getModel('vendor/model')->load(1);
$model->setName('Test'); // THIS IS THE SAME
$model->setDescription('Info'); // THIS IS THE SAME
var_dump($model->hasDataChanges()); // returns true! (i expect false)
var_dump(($model->getData() !== $model->getOrigData())) // returns false (expected)
Surely the latter is how Magento should behave? Unless i'm missing something.
Best Answer
Looking into the
setData
function it appears that has data changes is always set to true even if technically the data has not changes.This can be seen in
Varien_Object function setData