Created
July 10, 2012 08:28
-
-
Save cmuench/3082029 to your computer and use it in GitHub Desktop.
Magento: Save multiple models in one transaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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