Skip to content

Instantly share code, notes, and snippets.

@marcusthor
Forked from cmuench/gist:3082029
Created October 23, 2012 15:20
Show Gist options
  • Save marcusthor/3939390 to your computer and use it in GitHub Desktop.
Save marcusthor/3939390 to your computer and use it in GitHub Desktop.
Magento: Save multiple models in one transaction
<?php
// $foo = Mage::getModel('.....
// $bar = Mage::getModel('.....
$transaction = Mage::getModel('core/resource_transaction');
$transaction->addObject($foo);
$transaction->addObject($bar);
$transaction->save(); // runs save on all objects. On error -> rollback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment