From 8ac4cb9c430a162d3ae904ef63fb8a9702992fa0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Feb 2018 16:33:50 +0100 Subject: [PATCH] Add fetch_product --- htdocs/core/class/commonobject.class.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fd221649141..5235e59ef34 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1231,7 +1231,7 @@ abstract class CommonObject } /** - * Charge le projet d'id $this->fk_project dans this->projet + * Load the project with id $this->fk_project into this->project * * @return int <0 if KO, >=0 if OK */ @@ -1251,7 +1251,25 @@ abstract class CommonObject } /** - * Charge le user d'id userid dans this->user + * Load the product with id $this->fk_product into this->product + * + * @return int <0 if KO, >=0 if OK + */ + function fetch_product() + { + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + if (empty($this->fk_product)) return 0; + + $product = new Product($this->db); + $result = $product->fetch($this->fk_product); + + $this->product = $product; + return $result; + } + + /** + * Load the user with id $userid into this->user * * @param int $userid Id du contact * @return int <0 if KO, >0 if OK