61 public $fk_prod_combination;
75 public $fk_prod_attr_val;
87 public $errors = array();
106 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductAttributeValue.class.php';
107 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductAttribute.class.php';
112 $prodattr->fetch($this->fk_prod_attr);
113 $prodattrval->fetch($this->fk_prod_attr_val);
115 return $prodattr->label .
': ' . $prodattrval->value;
126 $sql =
"INSERT INTO " . MAIN_DB_PREFIX .
"product_attribute_combination2val
127 (fk_prod_combination, fk_prod_attr, fk_prod_attr_val)
128 VALUES(" . (int) $this->fk_prod_combination .
", " . (
int) $this->fk_prod_attr .
", " . (int) $this->fk_prod_attr_val .
")";
130 $query = $this->db->query($sql);
133 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX .
'product_attribute_combination2val');
151 c2v.fk_prod_attr_val,
153 c2v.fk_prod_combination
154 FROM " . MAIN_DB_PREFIX .
"product_attribute c LEFT JOIN " . MAIN_DB_PREFIX .
"product_attribute_combination2val c2v ON c.rowid = c2v.fk_prod_attr
155 WHERE c2v.fk_prod_combination = " . (int) $fk_combination;
157 $sql .= $this->db->order(
'c.position',
'asc');
159 $query = $this->db->query($sql);
167 while ($obj = $this->db->fetch_object($query)) {
169 $tmp->fk_prod_attr_val = $obj->fk_prod_attr_val;
170 $tmp->fk_prod_attr = $obj->fk_prod_attr;
171 $tmp->fk_prod_combination = $obj->fk_prod_combination;
172 $tmp->id = $obj->rowid;
188 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val WHERE fk_prod_combination = " . (int) $fk_combination;
190 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.