From 8fbf853b9421d0788469d72f9de18caeecfc0ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Tue, 19 Nov 2019 14:40:50 +0100 Subject: [PATCH] Display attributes infos when get product variants --- htdocs/product/class/api_products.class.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index fd564b17278..1d71246cab7 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1133,7 +1133,14 @@ class Products extends DolibarrApi } $prodcomb = new ProductCombination($this->db); - return $prodcomb->fetchAllByFkProductParent((int) $id); + $combinations = $prodcomb->fetchAllByFkProductParent((int) $id); + + foreach ($combinations as $key => $combination) { + $prodc2vp = new ProductCombination2ValuePair($this->db); + $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); + } + + return $combinations; } /** @@ -1159,7 +1166,14 @@ class Products extends DolibarrApi } $prodcomb = new ProductCombination($this->db); - return $prodcomb->fetchAllByFkProductParent((int) $this->product->id); + $combinations = $prodcomb->fetchAllByFkProductParent((int) $this->product->id); + + foreach ($combinations as $key => $combination) { + $prodc2vp = new ProductCombination2ValuePair($this->db); + $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); + } + + return $combinations; } /**