Beispiel #1
0
 /**
  * Prepares data for saving and removes update time (if exists).
  * This prevents saving same update time on each entity update.
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return array
  */
 protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $data = parent::_prepareDataForTable($object, $this->getMainTable());
     if (isset($data['updated_at'])) {
         unset($data['updated_at']);
     }
     return $data;
 }
Beispiel #2
0
 /**
  * Use qty correction for qty column update
  *
  * @param \Magento\Framework\Object $object
  * @param string $table
  * @return array
  */
 protected function _prepareDataForTable(\Magento\Framework\Object $object, $table)
 {
     $data = parent::_prepareDataForTable($object, $table);
     $ifNullSql = $this->_getWriteAdapter()->getIfNullSql('qty');
     if (!$object->isObjectNew() && $object->getQtyCorrection()) {
         if ($object->getQty() === null) {
             $data['qty'] = null;
         } elseif ($object->getQtyCorrection() < 0) {
             $data['qty'] = new \Zend_Db_Expr($ifNullSql . '-' . abs($object->getQtyCorrection()));
         } else {
             $data['qty'] = new \Zend_Db_Expr($ifNullSql . '+' . $object->getQtyCorrection());
         }
     }
     return $data;
 }