42 public $fk_product_parent;
48 public $fk_product_child;
54 public $variation_price;
60 public $variation_price_percentage =
false;
66 public $variation_weight;
78 public $combination_price_levels;
84 public $variation_ref_ext =
'';
96 $this->entity = $conf->entity;
109 $sql =
"SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext FROM ".MAIN_DB_PREFIX.
"product_attribute_combination WHERE rowid = ".((int) $rowid).
" AND entity IN (".
getEntity(
'product').
")";
111 $query = $this->
db->query($sql);
117 if (!$this->
db->num_rows($query)) {
121 $obj = $this->
db->fetch_object($query);
123 $this->
id = $obj->rowid;
124 $this->fk_product_parent = $obj->fk_product_parent;
125 $this->fk_product_child = $obj->fk_product_child;
126 $this->variation_price = $obj->variation_price;
127 $this->variation_price_percentage = $obj->variation_price_percentage;
128 $this->variation_weight = $obj->variation_weight;
129 $this->variation_ref_ext = $obj->variation_ref_ext;
131 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
151 if (!empty($this->combination_price_levels) && $useCache) {
152 if ((!empty($fk_price_level) && isset($this->combination_price_levels[$fk_price_level])) || empty($fk_price_level)) {
157 if (!is_array($this->combination_price_levels)
158 || empty($fk_price_level)
160 $this->combination_price_levels = array();
164 $combination_price_levels = $staticProductCombinationLevel->fetchAll($this->
id, $fk_price_level);
166 if (!is_array($combination_price_levels)) {
170 if (empty($combination_price_levels)) {
174 if ($fk_price_level > 0) {
177 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
183 $this->combination_price_levels = $combination_price_levels;
203 if (empty($this->combination_price_levels)) {
204 return $staticProductCombinationLevel->deleteAllForCombination($this->
id);
209 $res = $staticProductCombinationLevel->clean($this->
id);
211 $this->errors[] =
'Fail to clean not needed price levels';
216 foreach ($this->combination_price_levels as $fk_price_level => $combination_price_level) {
217 $res = $combination_price_level->save();
219 $this->error =
'Error saving combination price level '.$fk_price_level.
' : '.$combination_price_level->error;
220 $this->errors[] = $this->error;
244 $sql =
"SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight";
245 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_attribute_combination WHERE fk_product_child = ".((int) $productid).
" AND entity IN (".
getEntity(
'product').
")";
247 $query = $this->
db->query($sql);
253 if (!$this->
db->num_rows($query)) {
257 $result = $this->
db->fetch_object($query);
259 $this->
id = $result->rowid;
260 $this->fk_product_parent = $result->fk_product_parent;
261 $this->fk_product_child = $result->fk_product_child;
262 $this->variation_price = $result->variation_price;
263 $this->variation_price_percentage = $result->variation_price_percentage;
264 $this->variation_weight = $result->variation_weight;
266 if (empty($donotloadpricelevel) && !empty($conf->global->PRODUIT_MULTIPRICES)) {
270 return (
int) $this->fk_product_parent;
283 $sql =
"SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_ref_ext, variation_weight";
284 $sql.=
" FROM ".MAIN_DB_PREFIX.
"product_attribute_combination";
285 $sql.=
" WHERE fk_product_parent = ".((int) $fk_product_parent).
" AND entity IN (".
getEntity(
'product').
")";
287 $query = $this->
db->query($sql);
295 while ($result = $this->
db->fetch_object($query)) {
297 $tmp->id = $result->rowid;
298 $tmp->fk_product_parent = $result->fk_product_parent;
299 $tmp->fk_product_child = $result->fk_product_child;
300 $tmp->variation_price = $result->variation_price;
301 $tmp->variation_price_percentage = $result->variation_price_percentage;
302 $tmp->variation_weight = $result->variation_weight;
303 $tmp->variation_ref_ext = $result->variation_ref_ext;
305 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
306 $tmp->fetchCombinationPriceLevels();
324 $sql =
"SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX.
"product_attribute_combination WHERE fk_product_parent = ".((int) $fk_product_parent).
" AND entity IN (".
getEntity(
'product').
")";
328 $obj = $this->
db->fetch_object(
$resql);
349 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_attribute_combination";
350 $sql .=
" (fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext, entity)";
351 $sql .=
" VALUES (".((int) $this->fk_product_parent).
", ".((int) $this->fk_product_child).
",";
352 $sql .= (
float) $this->variation_price.
", ".(
int) $this->variation_price_percentage.
",";
353 $sql .= (
float) $this->variation_weight.
", '".$this->db->escape($this->variation_ref_ext).
"', ".(int) $this->entity.
")";
355 $resql = $this->db->query($sql);
357 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
'product_attribute_combination');
359 $this->error = $this->
db->lasterror();
363 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
383 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_attribute_combination";
384 $sql .=
" SET fk_product_parent = ".(int) $this->fk_product_parent.
", fk_product_child = ".(
int) $this->fk_product_child.
",";
385 $sql .=
" variation_price = ".(float) $this->variation_price.
", variation_price_percentage = ".(
int) $this->variation_price_percentage.
",";
386 $sql .=
" variation_ref_ext = '".$this->db->escape($this->variation_ref_ext).
"',";
387 $sql .=
" variation_weight = ".(float) $this->variation_weight.
" WHERE rowid = ".((
int) $this->id);
394 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
402 $parent->fetch($this->fk_product_parent);
415 public function delete(
User $user)
420 $comb2val->deleteByFkCombination($this->
id);
423 if (!$this->
db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"product_attribute_combination_price_level WHERE fk_product_attribute_combination = ".(
int) $this->id)) {
424 $this->
db->rollback();
428 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_attribute_combination WHERE rowid = ".(int) $this->
id;
430 if ($this->
db->query($sql)) {
435 $this->
db->rollback();
453 $res = $prodstatic->fetch($prodcomb->fk_product_child);
456 $res = $prodcomb->delete($user);
459 if ($res > 0 && !$prodstatic->isObjectUsed($prodstatic->id)) {
460 $res = $prodstatic->delete($user);
464 $this->
db->rollback();
488 $child->fetch($this->fk_product_child);
490 $child->price_autogen = $parent->price_autogen;
491 $child->weight = $parent->weight;
493 if (!empty($parent->oldcopy) && ($parent->status != $parent->oldcopy->status)) {
494 $child->status = $parent->status;
496 if (!empty($parent->oldcopy) && ($parent->status_buy != $parent->oldcopy->status_buy)) {
497 $child->status_buy = $parent->status_buy;
500 if ($this->variation_weight) {
501 $child->weight = ($child->weight ? $child->weight : 0) + $this->variation_weight;
503 $child->weight_units = $parent->weight_units;
506 if ($child->label == $parent->label) {
509 $child->label = $parent->label.$varlabel;
513 if ($child->update($child->id, $user) > 0) {
514 $new_vat = $parent->tva_tx;
515 $new_npr = $parent->tva_npr;
518 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
519 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
520 if ($parent->multiprices[$i] !=
'' || isset($this->combination_price_levels[$i]->variation_price)) {
521 $new_type = empty($parent->multiprices_base_type[$i]) ?
'HT' : $parent->multiprices_base_type[$i];
522 $new_min_price = $parent->multiprices_min[$i];
523 $variation_price = floatval(!isset($this->combination_price_levels[$i]->variation_price) ? $this->variation_price : $this->combination_price_levels[$i]->variation_price);
524 $variation_price_percentage = floatval(!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage);
526 if ($parent->prices_by_qty_list[$i]) {
532 if ($new_type ==
'TTC') {
533 $new_price = $parent->multiprices_ttc[$i];
535 $new_price = $parent->multiprices[$i];
538 if ($variation_price_percentage) {
539 if ($new_price != 0) {
540 $new_price *= 1 + ($variation_price / 100);
543 $new_price += $variation_price;
546 $ret = $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq, 0, array(), $parent->default_vat_code);
549 $this->
db->rollback();
550 $this->error = $child->error;
551 $this->errors = $child->errors;
557 $new_type = $parent->price_base_type;
558 $new_min_price = $parent->price_min;
559 $new_psq = $parent->price_by_qty;
561 if ($new_type ==
'TTC') {
562 $new_price = $parent->price_ttc;
564 $new_price = $parent->price;
567 if ($this->variation_price_percentage) {
568 if ($new_price != 0) {
569 $new_price *= 1 + ($this->variation_price / 100);
572 $new_price += $this->variation_price;
575 $ret = $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, 1, $new_npr, $new_psq);
578 $this->
db->rollback();
579 $this->error = $child->error;
580 $this->errors = $child->errors;
590 $this->
db->rollback();
591 $this->error = $child->error;
592 $this->errors = $child->errors;
605 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination2ValuePair.class.php';
607 $actual_comp = array();
612 $features = array_filter($features,
function ($v) {
616 foreach ($features as $attr => $attr_val) {
617 $actual_comp[$attr] = $attr_val;
620 foreach ($prodcomb->fetchAllByFkProductParent($prodid) as $prc) {
623 foreach ($prodcomb2val->fetchByFkCombination($prc->id) as $value) {
624 $values[$value->fk_prod_attr] = $value->fk_prod_attr_val;
627 $check1 = count(array_diff_assoc($values, $actual_comp));
628 $check2 = count(array_diff_assoc($actual_comp, $values));
630 if (!$check1 && !$check2) {
646 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
647 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttributeValue.class.php';
652 $sql =
"SELECT DISTINCT fk_prod_attr, a.position";
653 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_attribute_combination2val c2v LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination c ON c2v.fk_prod_combination = c.rowid";
654 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product p ON p.rowid = c.fk_product_child";
655 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute a ON a.rowid = fk_prod_attr";
656 $sql .=
" WHERE c.fk_product_parent = ".((int) $productid).
" AND p.tosell = 1";
657 $sql .= $this->
db->order(
'a.position',
'asc');
659 $query = $this->
db->query($sql);
662 while ($result = $this->
db->fetch_object($query)) {
664 $attr->fetch($result->fk_prod_attr);
666 $tmp =
new stdClass();
667 $tmp->id = $attr->id;
668 $tmp->ref = $attr->ref;
669 $tmp->label = $attr->label;
670 $tmp->values = array();
673 foreach ($res = $attrval->fetchAllByProductAttribute($attr->id,
true) as $val) {
674 $tmp->values[] = $val;
706 public function createProductCombination(
User $user,
Product $product, array $combinations, array $variations, $price_var_percent =
false, $forced_pricevar =
false, $forced_weightvar =
false, $forced_refvar =
false, $ref_ext =
'')
710 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
711 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttributeValue.class.php';
715 $price_impact = array(1=>0);
717 $forced_refvar = trim($forced_refvar);
719 if (!empty($forced_refvar) && $forced_refvar != $product->ref) {
720 $existingProduct =
new Product($this->
db);
721 $result = $existingProduct->fetch(
'', $forced_refvar);
723 $newproduct = $existingProduct;
725 $existingProduct =
false;
726 $newproduct = clone $product;
727 $newproduct->ref = $forced_refvar;
730 $forced_refvar =
false;
731 $existingProduct =
false;
732 $newproduct = clone $product;
736 $weight_impact = (
float) $forced_weightvar;
739 if (!is_array($forced_pricevar)) {
740 $price_impact[1] = (
float) $forced_pricevar;
742 $price_impact = $forced_pricevar;
745 if (!array($price_var_percent)) {
746 $price_var_percent[1] = (
float) $price_var_percent;
750 $existingCombination = $newcomb->fetchByProductCombination2ValuePairs($product->id, $combinations);
752 if ($existingCombination) {
753 $newcomb = $existingCombination;
755 $newcomb->fk_product_parent = $product->id;
758 $result = $newcomb->create($user);
760 $this->error = $newcomb->error;
761 $this->errors = $newcomb->errors;
762 $this->
db->rollback();
772 foreach ($combinations as $currcombattr => $currcombval) {
774 $prodattr->fetch($currcombattr);
775 $prodattrval->fetch($currcombval);
778 if (!$existingCombination) {
780 $tmp->fk_prod_attr = $currcombattr;
781 $tmp->fk_prod_attr_val = $currcombval;
782 $tmp->fk_prod_combination = $newcomb->id;
784 if ($tmp->create($user) < 0) {
785 $this->error = $tmp->error;
786 $this->errors = $tmp->errors;
787 $this->
db->rollback();
792 if ($forced_weightvar ===
false) {
793 $weight_impact += (
float)
price2num($variations[$currcombattr][$currcombval][
'weight']);
795 if ($forced_pricevar ===
false) {
796 $price_impact[1] += (
float)
price2num($variations[$currcombattr][$currcombval][
'price']);
799 if ($conf->global->PRODUIT_MULTIPRICES) {
800 for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
801 $price_impact[$i] += (
float)
price2num($variations[$currcombattr][$currcombval][
'price']);
806 if ($forced_refvar ===
false) {
807 if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) {
808 $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR.$prodattrval->ref;
810 $newproduct->ref .=
'_'.$prodattrval->ref;
815 if ($newproduct->description) {
816 $newproduct->description .=
'<br>';
818 $newproduct->description .=
'<strong>'.$prodattr->label.
':</strong> '.$prodattrval->value;
821 $newcomb->variation_price_percentage = $price_var_percent[1];
822 $newcomb->variation_price = $price_impact[1];
823 $newcomb->variation_weight = $weight_impact;
824 $newcomb->variation_ref_ext = $this->
db->escape($ref_ext);
827 if ($conf->global->PRODUIT_MULTIPRICES) {
828 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
830 $productCombinationLevel->fk_product_attribute_combination = $newcomb->id;
831 $productCombinationLevel->fk_price_level = $i;
832 $productCombinationLevel->variation_price = $price_impact[$i];
834 if (is_array($price_var_percent)) {
835 $productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]);
837 $productCombinationLevel->variation_price_percentage = $price_var_percent;
840 $newcomb->combination_price_levels[$i] = $productCombinationLevel;
845 $newproduct->weight += $weight_impact;
849 if ($existingProduct ===
false) {
851 $newproduct->price = 0;
852 $newproduct->price_ttc = 0;
853 $newproduct->price_min = 0;
854 $newproduct->price_min_ttc = 0;
857 $newproduct->barcode = -1;
858 $result = $newproduct->create($user);
862 if ($newproduct->error !=
'ErrorProductAlreadyExists') {
863 $this->error[] = $newproduct->error;
864 $this->errors = $newproduct->errors;
865 $this->
db->rollback();
874 if ($newcomb->fk_product_child) {
875 $res = $newproduct->fetch($existingCombination->fk_product_child);
877 $orig_prod_ref = $newproduct->ref;
881 $newproduct->ref = $orig_prod_ref.$i;
882 $res = $newproduct->create($user);
884 if ($newproduct->error !=
'ErrorProductAlreadyExists') {
885 $this->errors[] = $newproduct->error;
894 $this->
db->rollback();
899 $result = $newproduct->update($newproduct->id, $user);
901 $this->
db->rollback();
906 $newcomb->fk_product_child = $newproduct->id;
908 if ($newcomb->update($user) < 0) {
909 $this->error = $newcomb->error;
910 $this->errors = $newcomb->errors;
911 $this->
db->rollback();
916 return $newproduct->id;
929 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination2ValuePair.class.php';
932 if ($origProductId == $destProduct->id) {
941 foreach ($combinations as $combination) {
942 $variations = array();
944 foreach ($prodcomb2val->fetchByFkCombination($combination->id) as $tmp_pc2v) {
945 $variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val;
953 $combination->variation_price_percentage,
954 $combination->variation_price,
955 $combination->variation_weight
972 $sql =
'SELECT pav.value AS label';
973 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_attribute_combination pac';
974 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product_attribute_combination2val pac2v ON pac2v.fk_prod_combination=pac.rowid';
975 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product_attribute_value pav ON pav.rowid=pac2v.fk_prod_attr_val';
976 $sql .=
' WHERE pac.fk_product_child='.((int) $prod_child);
985 $obj = $this->
db->fetch_object(
$resql);
988 $label .=
' '.$obj->label;
1014 public $table_element =
'product_attribute_combination_price_level';
1026 public $fk_product_attribute_combination;
1032 public $fk_price_level;
1038 public $variation_price;
1044 public $variation_price_percentage =
false;
1064 $sql =
"SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage";
1065 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element;
1066 $sql .=
" WHERE rowid = ".(int) $rowid;
1070 $obj = $this->
db->fetch_object(
$resql);
1087 public function fetchAll($fk_product_attribute_combination, $fk_price_level = 0)
1091 $sql =
"SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage";
1092 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element;
1093 $sql .=
" WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination);
1094 if (!empty($fk_price_level)) {
1095 $sql .=
' AND fk_price_level = '.intval($fk_price_level);
1098 $res = $this->
db->query($sql);
1100 if ($this->
db->num_rows($res) > 0) {
1101 while ($obj = $this->
db->fetch_object($res)) {
1103 $productCombinationLevel->fetchFormObj($obj);
1104 $result[$obj->fk_price_level] = $productCombinationLevel;
1126 $this->
id = $obj->rowid;
1127 $this->fk_product_attribute_combination = floatval($obj->fk_product_attribute_combination);
1128 $this->fk_price_level = intval($obj->fk_price_level);
1129 $this->variation_price = floatval($obj->variation_price);
1130 $this->variation_price_percentage = (bool) $obj->variation_price_percentage;
1143 if (($this->
id > 0 && empty($this->fk_product_attribute_combination)) || empty($this->fk_price_level)) {
1148 if ($this->fk_product_attribute_combination > 0 && empty($this->
id)) {
1149 $sql =
"SELECT rowid id";
1150 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element;
1151 $sql .=
" WHERE fk_product_attribute_combination = ".(int) $this->fk_product_attribute_combination;
1152 $sql .=
' AND fk_price_level = '.((int) $this->fk_price_level);
1156 $obj = $this->
db->fetch_object(
$resql);
1158 $this->
id = $obj->id;
1164 if (!empty($this->
id)) {
1165 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
1166 $sql .=
' SET variation_price = '.floatval($this->variation_price).
' , variation_price_percentage = '.intval($this->variation_price_percentage);
1167 $sql .=
' WHERE rowid = '.((int) $this->
id);
1169 $res = $this->
db->query($sql);
1173 $this->error = $this->
db->error();
1174 $this->errors[] = $this->error;
1179 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.$this->table_element.
" (";
1180 $sql .=
"fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage";
1181 $sql .=
") VALUES (";
1182 $sql .= (int) $this->fk_product_attribute_combination;
1183 $sql .=
", ".intval($this->fk_price_level);
1184 $sql .=
", ".floatval($this->variation_price);
1185 $sql .=
", ".intval($this->variation_price_percentage);
1188 $res = $this->
db->query($sql);
1190 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
1192 $this->error = $this->
db->error();
1193 $this->errors[] = $this->error;
1207 public function delete()
1209 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element.
" WHERE rowid = ".(int) $this->
id;
1210 $res = $this->
db->query($sql);
1212 return $res ? 1 : -1;
1224 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element.
" WHERE fk_product_attribute_combination = ".(int) $fk_product_attribute_combination;
1225 $res = $this->
db->query($sql);
1227 return $res ? 1 : -1;
1237 public function clean($fk_product_attribute_combination)
1241 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
1242 $sql .=
" WHERE fk_product_attribute_combination = ".(int) $fk_product_attribute_combination;
1243 $sql .=
" AND fk_price_level > ".intval($conf->global->PRODUIT_MULTIPRICES_LIMIT);
1244 $res = $this->
db->query($sql);
1246 return $res ? 1 : -1;
1260 $productCombinationLevel =
new self($db);
1261 $productCombinationLevel->fk_price_level = $fkPriceLevel;
1262 $productCombinationLevel->fk_product_attribute_combination = $productCombination->id;
1263 $productCombinationLevel->variation_price = $productCombination->variation_price;
1264 $productCombinationLevel->variation_price_percentage = (bool) $productCombination->variation_price_percentage;
1266 return $productCombinationLevel;
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,...
Class ProductCombination Used to represent a product combination.
fetchAllByFkProductParent($fk_product_parent)
Retrieves all product combinations by the product parent row id.
update(User $user)
Updates a product combination.
countNbOfCombinationForFkProductParent($fk_product_parent)
Retrieves all product combinations by the product parent row id.
getUniqueAttributesAndValuesByFkProductParent($productid)
Retrieves all unique attributes for a parent product.
fetchCombinationPriceLevels($fk_price_level=0, $useCache=true)
Retrieves combination price levels.
deleteByFkProductParent($user, $fk_product_parent)
Deletes all product combinations of a parent product.
updateProperties(Product $parent, User $user)
Updates the weight of the child product.
fetchByFkProductChild($productid, $donotloadpricelevel=0)
Retrieves information of a variant product and ID of its parent product.
copyAll(User $user, $origProductId, Product $destProduct)
Copies all product combinations from the origin product to the destination product.
__construct(DoliDB $db)
Constructor.
createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent=false, $forced_pricevar=false, $forced_weightvar=false, $forced_refvar=false, $ref_ext='')
Creates a product combination.
create($user)
Creates a product attribute combination.
saveCombinationPriceLevels($clean=1)
Retrieves combination price levels.
getCombinationLabel($prod_child)
Return label for combinations.
fetchByProductCombination2ValuePairs($prodid, array $features)
Retrieves the combination that matches the given features.
fetch($rowid)
Retrieves a combination by its rowid.
Class ProductCombinationLevel Used to represent a product combination Level.
static createFromParent(DoliDB $db, ProductCombination $productCombination, $fkPriceLevel)
Create new Product Combination Price level from Parent.
save()
Save a price impact of a product combination for a price level.
clean($fk_product_attribute_combination)
Clean not needed price levels for a combination.
fetchAll($fk_product_attribute_combination, $fk_price_level=0)
Retrieves combination price levels.
deleteAllForCombination($fk_product_attribute_combination)
delete all for a combination
fetchFormObj($obj)
Assign vars form an stdclass like sql obj.
__construct(DoliDB $db)
Constructor.
fetch($rowid)
Retrieves a combination level by its rowid.
Class to manage products or services.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
div float
Buy price without taxes.
$conf db
API class for accounts.