Jump to content

Update stock script returns duplicate entry error


Recommended Posts

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'];
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
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...