spearmootz Posted April 17, 2015 Share Posted April 17, 2015 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 Link to comment Share on other sites More sharing options...
Tuni-Soft Posted April 18, 2015 Share Posted April 18, 2015 You can use this method directly StockAvailable::setQuantity((int)$id_product, (int)$id_attribute, (int)$updates[$key]['stock'], (int)$store) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now