Here is a complete script that will update everything in the database. You will then need to clear the cache.
Upload the file to the root of the eshop and run it in the address bar.
E.g.: https://my-shop.com/update-attributes-stock.php
Sample code:
include_once('./config/config.inc.php'); $db = Db::getInstance(); $sql = 'SELECT a.id_product FROM '._DB_PREFIX_.'stock_available a WHERE a.id_product_attribute > 0 GROUP BY a.id_product'; $products = Db::getInstance()->ExecuteS( $sql ); if ($products) { foreach($products as $product) { $getAttributesQty = $db->getvalue('SELECT SUM(a.quantity) as qty FROM '._DB_PREFIX_.'stock_available a WHERE a.id_product = '.$product['id_product'].' AND a.id_product_attribute > 0'); $getAttributesPhysicalQty = $db->getvalue('SELECT SUM(a.physical_quantity) as qty FROM '._DB_PREFIX_.'stock_available a WHERE a.id_product = '.$product['id_product'].' AND a.id_product_attribute > 0'); $db->update('stock_available', array('quantity' => $getAttributesQty, 'physical_quantity' => $getAttributesPhysicalQty), 'id_product = '.$product['id_product'].' AND id_product_attribute = 0'); echo 'updated product: '.$product['id_product'].' | quantity: '.$getAttributesQty.' | physical quantity: '.$getAttributesPhysicalQty.'<br>'; } }