so here is my code to update stock, i am getting a duplicate entry error. i do not want to create a new stock as it exists, just update it.
$id_stock_available = (int)StockAvailable::getStockAvailableIdByProductId((int) $id_product, (int) $id_attribute, (int) $store);
if ($id_stock_available)
{
$stock_available = new StockAvailable($id_stock_available);
$stock_available->quantity = (int)$updates[$key]['stock'];
$stock_available->update();
}
whenever the update function is ran i get the following error. I do no understand, im not trying to insert a new one. i am trying to update an old quantity
Fatal error: Uncaught Duplicate entry '16792-0-0-2' for key 'product_sqlstock'<br /><br /><pre>INSERT INTO `ps_stock_available` (`id_product`, `id_product_attribute`, `id_shop`, `id_shop_group`, `quantity`, `depends_on_stock`, `out_of_stock`) VALUES ('16792', '0', '0', '2', '20', '0', '0')</pre> thrown in C:\wamp\www\prestashop\classes\db\Db.php on line 646