Skip to content

Instantly share code, notes, and snippets.

@astorm
Created March 22, 2013 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astorm/5219357 to your computer and use it in GitHub Desktop.
Save astorm/5219357 to your computer and use it in GitHub Desktop.
#File: app/code/core/Mage/Core/Model/Resource/Db/Abstract.php
public function forsedSave(Mage_Core_Model_Abstract $object)
{
$this->_beforeSave($object);
$bind = $this->_prepareDataForSave($object);
$adapter = $this->_getWriteAdapter();
// update
if (!is_null($object->getId()) && $this->_isPkAutoIncrement) {
unset($bind[$this->getIdFieldName()]);
$condition = $adapter->quoteInto($this->getIdFieldName().'=?', $object->getId());
$adapter->update($this->getMainTable(), $bind, $condition);
} else {
$adapter->insertOnDuplicate($this->getMainTable(), $bind, $this->_fieldsForUpdate);
$object->setId($adapter->lastInsertId($this->getMainTable()));
}
$this->_afterSave($object);
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment