In the products_with_attributes_stock class you'll find this short function
Code:
function update_parent_products_stock($products_id)
{
global $db;
$query = 'select sum(quantity) as quantity from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.' where products_id = "'.(int)$products_id.'"';
$quantity = $db->Execute($query);
$query = 'update '.TABLE_PRODUCTS.' set products_quantity="'.$quantity->fields['quantity'].'" where products_id="'.(int)$products_id.'"';
$db->Execute($query);
}
It first collects the summed total for a product's attribute variants and then applies it to the product table for that product.
To avoid the php and apply it to all products, you would probably want to create a database view or a temporary table based on the first query and then apply the resulting rows in that to all matching rows in the product table.
Bookmarks