41 public $fk_prod_combination;
53 public $fk_prod_attr_val;
63 public $errors = array();
82 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductAttributeValue.class.php';
83 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductAttribute.class.php';
88 $prodattr->fetch($this->fk_prod_attr);
89 $prodattrval->fetch($this->fk_prod_attr_val);
91 return $prodattr->label .
': ' . $prodattrval->value;
102 $sql =
"INSERT INTO " . MAIN_DB_PREFIX .
"product_attribute_combination2val
103 (fk_prod_combination, fk_prod_attr, fk_prod_attr_val)
104 VALUES(" . (int) $this->fk_prod_combination .
", " . (
int) $this->fk_prod_attr .
", " . (int) $this->fk_prod_attr_val .
")";
106 $query = $this->db->query($sql);
109 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX .
'product_attribute_combination2val');
127 c2v.fk_prod_attr_val,
129 c2v.fk_prod_combination
130 FROM " . MAIN_DB_PREFIX .
"product_attribute c LEFT JOIN " . MAIN_DB_PREFIX .
"product_attribute_combination2val c2v ON c.rowid = c2v.fk_prod_attr
131 WHERE c2v.fk_prod_combination = " . (int) $fk_combination;
133 $sql .= $this->db->order(
'c.position',
'asc');
135 $query = $this->db->query($sql);
143 while ($obj = $this->db->fetch_object($query)) {
145 $tmp->fk_prod_attr_val = $obj->fk_prod_attr_val;
146 $tmp->fk_prod_attr = $obj->fk_prod_attr;
147 $tmp->fk_prod_combination = $obj->fk_prod_combination;
148 $tmp->id = $obj->rowid;
164 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val WHERE fk_prod_combination = " . (int) $fk_combination;
166 if ($this->db->query($sql)) {
Class to manage Dolibarr database access.
Class ProductAttribute Used to represent a product attribute.
Class ProductAttributeValue Used to represent a product attribute value.
Class ProductCombination2ValuePair Used to represent the relation between a product combination,...
deleteByFkCombination($fk_combination)
Deletes a product combination 2 value pair.
fetchByFkCombination($fk_combination)
Retrieves a product combination 2 value pair from its rowid.
__construct(DoliDB $db)
Constructor.
create($user)
Creates a product combination 2 value pair.
__toString()
Translates this class to a human-readable string.