cikcak Posted November 11, 2014 Share Posted November 11, 2014 (edited) Ive noticed that after quantity UPDATE something wrong. It seems that after update stock in product list stay OLD. If I write manual a new value in product -> quantity it refresh to a good. This is example: http://prntscr.com/54wjk7 in product list we can see - 3 If I open product quantity i can see: http://prntscr.com/54wk2m - 1 in stock So this is a problem. My function to update quantities: function update_database($code,$count){ $res = mysql_query('SELECT `id_product_attribute`,`id_product` FROM `'._DB_PREFIX_.'product_attribute` WHERE `ean13` = \''.$code.'\' LIMIT 1'); if(mysql_num_rows($res)){ echo " ++. ".$count."<br/>"; $row = mysql_fetch_object($res); mysql_query('UPDATE `'._DB_PREFIX_.'product_attribute` SET `quantity` = \''.$count.'\' WHERE `ean13` = \''.$code.'\' '); mysql_query('UPDATE `'._DB_PREFIX_.'product` SET `quantity` = \''.$count.'\' WHERE `id_product` = \''.$row->id_product.'\' '); $id_product_attribute = $row->id_product_attribute; mysql_query('UPDATE `'._DB_PREFIX_.'stock_available` SET `quantity` = \''.$count.'\' WHERE `id_product_attribute` = \''.$id_product_attribute.'\' '); }else{ $res = mysql_query('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `ean13` = \''.$code.'\' LIMIT 1'); if(mysql_num_rows($res)){ echo " +++. ".$count."<br/>"; $row = mysql_fetch_object($res); $id_product = $row->id_product; mysql_query('UPDATE `'._DB_PREFIX_.'product` SET `quantity` = \''.$count.'\' WHERE `ean13` = \''.$code.'\' '); mysql_query('UPDATE `'._DB_PREFIX_.'stock_available` SET `quantity` = \''.$count.'\' WHERE `id_product` = \''.$id_product.'\' '); }else{ echo " --."; } } mysql_close($this->db); } Im using BAR code to update. Where is my fault? Thanks for help. Edited November 11, 2014 by cikcak (see edit history) 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