60 public $fk_prod_combination;
74 public $fk_prod_attr_val;
86 public $errors = array();
105 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductAttributeValue.class.php';
106 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductAttribute.class.php';
111 $prodattr->fetch($this->fk_prod_attr);
112 $prodattrval->fetch($this->fk_prod_attr_val);
114 return $prodattr->label .
': ' . $prodattrval->value;
125 $sql =
"INSERT INTO " . MAIN_DB_PREFIX .
"product_attribute_combination2val
126 (fk_prod_combination, fk_prod_attr, fk_prod_attr_val)
127 VALUES(" . (int) $this->fk_prod_combination .
", " . (
int) $this->fk_prod_attr .
", " . (int) $this->fk_prod_attr_val .
")";
129 $query = $this->db->query($sql);
132 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX .
'product_attribute_combination2val');
150 c2v.fk_prod_attr_val,
152 c2v.fk_prod_combination
153 FROM " . MAIN_DB_PREFIX .
"product_attribute c LEFT JOIN " . MAIN_DB_PREFIX .
"product_attribute_combination2val c2v ON c.rowid = c2v.fk_prod_attr
154 WHERE c2v.fk_prod_combination = " . (int) $fk_combination;
156 $sql .= $this->db->order(
'c.position',
'asc');
158 $query = $this->db->query($sql);
166 while ($obj = $this->db->fetch_object($query)) {
168 $tmp->fk_prod_attr_val = $obj->fk_prod_attr_val;
169 $tmp->fk_prod_attr = $obj->fk_prod_attr;
170 $tmp->fk_prod_combination = $obj->fk_prod_combination;
171 $tmp->id = $obj->rowid;
187 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val WHERE fk_prod_combination = " . (int) $fk_combination;
189 if ($this->db->query($sql)) {
Class to manage Dolibarr database access.
Class ProductAttribute Used to represent a Product attribute Examples:
Class ProductAttributeValue Used to represent a product attribute value.
Class ProductCombination2ValuePair Used to represent the relation between a variant and its attribute...
deleteByFkCombination($fk_combination)
Delete all ProductCombination2ValuePair linked to a given ProductCombination ID.
fetchByFkCombination($fk_combination)
Retrieve all ProductCombination2ValuePair linked to a given ProductCombination ID.
__construct(DoliDB $db)
Constructor.
create($user)
Create a ProductCombination2ValuePair.
__toString()
Translates this class to a human-readable string.