From ff0d7651bfd9cd7ff995238053ddd6880930870f Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Wed, 31 Aug 2016 11:55:14 +0200 Subject: [PATCH] fix total product attribute quantities --- override/classes/Product.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/override/classes/Product.php b/override/classes/Product.php index 1bbc4f60..ea9a4283 100644 --- a/override/classes/Product.php +++ b/override/classes/Product.php @@ -159,7 +159,7 @@ class Product extends ProductCore if ($row['id_product_attribute']) { - $row['quantity_all_versions'] = $row['quantity']; + $row['quantity_all_versions'] = Product::getTotalAttributeQuantity((int)$row['id_product']); $row['quantity'] = Product::getQuantity((int)$row['id_product'], $row['id_product_attribute'], isset($row['cache_is_pack']) ? $row['cache_is_pack'] : NULL); } $row['id_image'] = Product::defineProductImage($row, $id_lang); @@ -285,4 +285,15 @@ class Product extends ProductCore } return !$return ? false : $combinationImages; } + + public static function getTotalAttributeQuantity($id_product) + { + $quantity = Db::getInstance()->getValue(' + SELECT SUM(`quantity`) + FROM `'._DB_PREFIX_.'product_attribute` + WHERE `id_product` = '.(int)($id_product) + ); + + return $quantity; + } }