dolibarr 25.0.0-alpha
productlang.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
25
34{
38 public $module = 'product';
39
43 public $element = 'product_lang';
44
48 public $table_element = 'product_lang';
49
53 public $ismultientitymanaged = 0;
54
58 public $isextrafieldmanaged = 1;
59
63 public $fk_product;
64
68 public $lang;
69
73 public $label;
74
78 public $description;
79
83 public $note;
84
85
91 public function __construct($db)
92 {
93 $this->db = $db;
94 }
95
105 public function fetch($id = 0, $fk_product = 0, $lang = '')
106 {
107 $sql = "SELECT rowid, fk_product, lang, label, description, note";
108 $sql .= " FROM ".$this->db->prefix().$this->table_element;
109 if ($id > 0) {
110 $sql .= " WHERE rowid = ".((int) $id);
111 } else {
112 $sql .= " WHERE fk_product = ".((int) $fk_product)." AND lang = '".$this->db->escape($lang)."'";
113 }
114
115 $resql = $this->db->query($sql);
116 if (!$resql) {
117 $this->error = $this->db->lasterror();
118 return -1;
119 }
120
121 $obj = $this->db->fetch_object($resql);
122 $this->db->free($resql);
123 if (!$obj) {
124 return 0;
125 }
126
127 $this->id = (int) $obj->rowid;
128 $this->fk_product = (int) $obj->fk_product;
129 $this->lang = $obj->lang;
130 $this->label = $obj->label;
131 $this->description = $obj->description;
132 $this->note = $obj->note;
133
134 return 1;
135 }
136}
Class of a translation of a product (a row of llx_product_lang).
__construct($db)
Constructor.
fetch($id=0, $fk_product=0, $lang='')
Load a translation of a product from its id, or from the product and the language.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.