Skip to content

Commit 17937e0

Browse files
author
valdislav
committed
MAGETWO-36882: Stabilizing branch
1 parent 56c4093 commit 17937e0

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

app/code/Magento/Sales/Model/Resource/EntityAbstract.php

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ protected function processRelations(\Magento\Framework\Model\AbstractModel $obje
209209
* @param \Magento\Framework\Model\AbstractModel $object
210210
* @return $this
211211
* @throws \Exception
212-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
213212
*/
214213
public function save(\Magento\Framework\Model\AbstractModel $object)
215214
{
@@ -232,38 +231,12 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
232231
$this->objectRelationProcessor->validateDataIntegrity($this->getMainTable(), $object->getData());
233232
if ($object->getId() !== null && (!$this->_useIsObjectNew || !$object->isObjectNew())) {
234233
$condition = $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
235-
/**
236-
* Not auto increment primary key support
237-
*/
238-
if ($this->_isPkAutoIncrement) {
239-
$data = $this->prepareDataForUpdate($object);
240-
if (!empty($data)) {
241-
$this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition);
242-
}
243-
} else {
244-
$select = $this->_getWriteAdapter()->select()->from(
245-
$this->getMainTable(),
246-
[$this->getIdFieldName()]
247-
)->where(
248-
$condition
249-
);
250-
if ($this->_getWriteAdapter()->fetchOne($select) !== false) {
251-
$data = $this->prepareDataForUpdate($object);
252-
if (!empty($data)) {
253-
$this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition);
254-
}
255-
} else {
256-
$this->_getWriteAdapter()->insert(
257-
$this->getMainTable(),
258-
$this->_prepareDataForSave($object)
259-
);
260-
}
261-
}
234+
$data = $this->_prepareDataForSave($object);
235+
unset($data[$this->getIdFieldName()]);
236+
$this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition);
262237
} else {
263238
$bind = $this->_prepareDataForSave($object);
264-
if ($this->_isPkAutoIncrement) {
265-
unset($bind[$this->getIdFieldName()]);
266-
}
239+
unset($bind[$this->getIdFieldName()]);
267240
$this->_getWriteAdapter()->insert($this->getMainTable(), $bind);
268241

269242
$object->setId($this->_getWriteAdapter()->lastInsertId($this->getMainTable()));
@@ -272,10 +245,9 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
272245
$object->isObjectNew(false);
273246
}
274247
}
275-
276248
$this->unserializeFields($object);
277249
$this->_afterSave($object);
278-
250+
$this->entitySnapshot->registerSnapshot($object);
279251
$object->afterSave();
280252
$this->processRelations($object);
281253
}

0 commit comments

Comments
 (0)