コード例 #1
0
ファイル: Item.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * Use qty correction for qty column update
  *
  * @param \Magento\Framework\DataObject $object
  * @param string $table
  * @return array
  */
 protected function _prepareDataForTable(\Magento\Framework\DataObject $object, $table)
 {
     $data = parent::_prepareDataForTable($object, $table);
     $ifNullSql = $this->getConnection()->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;
 }