Commit a2e81d5f authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

Merge pull request #47 from fooman/allow-updating-existing-scopes

allow changing existing scopes
parents 5b0db121 ac9eb457
...@@ -801,26 +801,29 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -801,26 +801,29 @@ class EcomDev_PHPUnit_Model_Fixture
return false; return false;
} }
$scopeModel = Mage::getModel(self::$_scopeModelByType[$type]); $scopeModel = Mage::getModel(self::$_scopeModelByType[$type])->load($row[$type . '_id']);
$isNew = !$scopeModel->getId();
if ($isNew) {
// Change property for saving new objects with specified ids
EcomDev_Utils_Reflection::setRestrictedPropertyValues(
$scopeModel->getResource(),
array(
'_isPkAutoIncrement' => false
)
);
$scopeModel->isObjectNew(true);
}
$scopeModel->setData($row); $scopeModel->setData($row);
// Change property for saving new objects with specified ids
EcomDev_Utils_Reflection::setRestrictedPropertyValues(
$scopeModel->getResource(),
array(
'_isPkAutoIncrement' => false
)
);
$scopeModel->isObjectNew(true);
$scopeModel->save(); $scopeModel->save();
// Revert changed property if ($isNew) {
EcomDev_Utils_Reflection::setRestrictedPropertyValues( // Revert changed property
$scopeModel->getResource(), EcomDev_Utils_Reflection::setRestrictedPropertyValues(
array( $scopeModel->getResource(),
'_isPkAutoIncrement' => true array(
) '_isPkAutoIncrement' => true
); )
);
}
return $scopeModel; return $scopeModel;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment