From f93934905fba82d5d4acddb33388bf44fe6c0d50 Mon Sep 17 00:00:00 2001 From: Gerhard Stephan Date: Tue, 13 Feb 2018 08:41:57 +0100 Subject: [PATCH] Implemented a correct error handling, if the $line->product_ref has not been set --- htdocs/core/class/commondocgenerator.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index dee67990cdc..015173f1f05 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -529,10 +529,13 @@ abstract class CommonDocGenerator $resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs); // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" - $product = new Product($this->db); - $result = $product->fetch(null, $line->product_ref); - foreach($product->array_options as $key=>$label) - $resarray["line_".$key] = $label; + if (isset($line->product_ref)) + { + $product = new Product($this->db); + $result = $product->fetch(null, $line->product_ref); + foreach($product->array_options as $key=>$label) + $resarray["line_".$key] = $label; + } return $resarray; }