Skip to content

Commit a1be5e6

Browse files
committed
MAGETWO-65586: [GitHub][PR] FIX Backend mass delete Sql error #8079
- Merge Pull Request #8079 from asubit/magento2:asubit-patch-1
2 parents 3f75fac + 2d621dd commit a1be5e6

File tree

1 file changed

+4
-1
lines changed
  • app/code/Magento/Quote/Model/ResourceModel

1 file changed

+4
-1
lines changed

app/code/Magento/Quote/Model/ResourceModel/Quote.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,17 @@ public function substractProductFromQuotes($product)
242242
}
243243
$connection = $this->getConnection();
244244
$subSelect = $connection->select();
245+
$conditionCheck = $connection->quoteIdentifier('q.items_count') . " > 0";
246+
$conditionTrue = $connection->quoteIdentifier('q.items_count') . ' - 1';
247+
$ifSql = "IF (" . $conditionCheck . "," . $conditionTrue . ", 0)";
245248

246249
$subSelect->from(
247250
false,
248251
[
249252
'items_qty' => new \Zend_Db_Expr(
250253
$connection->quoteIdentifier('q.items_qty') . ' - ' . $connection->quoteIdentifier('qi.qty')
251254
),
252-
'items_count' => new \Zend_Db_Expr($connection->quoteIdentifier('q.items_count') . ' - 1')
255+
'items_count' => new \Zend_Db_Expr($ifSql)
253256
]
254257
)->join(
255258
['qi' => $this->getTable('quote_item')],

0 commit comments

Comments
 (0)