public function correctItemsQty($stock, $productQtys, $operator = '-')
{
if (empty($productQtys)) {
return $this;
}
$adapter = $this->_getWriteAdapter();
$conditions = array();
foreach ($productQtys as $productId => $qty) {
$case = $adapter->quoteInto('?', $productId);
$result = $adapter->quoteInto("qty{$operator}?", $qty);
$conditions[$case] = $result;
}
$value = $adapter->getCaseSql('product_id', $conditions, 'qty');
$where = array(
'product_id IN (?)' => array_keys($productQtys),
'stock_id = ?' => $stock->getId()
);
$adapter->beginTransaction();
$adapter->update($this->getTable('cataloginventory/stock_item'), array('qty' => $value), $where);
$adapter->commit();
return $this;
}