dolibarr 19.0.4
|
Class ProductCombination Used to represent a product combination. More...
Public Member Functions | |
__construct (DoliDB $db) | |
Constructor. | |
fetch ($rowid) | |
Retrieves a combination by its rowid. | |
fetchCombinationPriceLevels ($fk_price_level=0, $useCache=true) | |
Retrieves combination price levels. | |
saveCombinationPriceLevels ($clean=1) | |
Retrieves combination price levels. | |
fetchByFkProductChild ($productid, $donotloadpricelevel=0) | |
Retrieves information of a variant product and ID of its parent product. | |
fetchAllByFkProductParent ($fk_product_parent) | |
Retrieves all product combinations by the product parent row id. | |
countNbOfCombinationForFkProductParent ($fk_product_parent) | |
Retrieves all product combinations by the product parent row id. | |
create ($user) | |
Creates a product attribute combination. | |
update (User $user) | |
Updates a product combination. | |
delete (User $user) | |
Deletes a product combination. | |
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. | |
fetchByProductCombination2ValuePairs ($prodid, array $features) | |
Retrieves the combination that matches the given features. | |
getUniqueAttributesAndValuesByFkProductParent ($productid) | |
Retrieves all unique attributes for a parent product. | |
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. | |
copyAll (User $user, $origProductId, Product $destProduct) | |
Copies all product combinations from the origin product to the destination product. | |
getCombinationLabel ($prod_child) | |
Return label for combinations. | |
Class ProductCombination Used to represent a product combination.
Definition at line 24 of file ProductCombination.class.php.
ProductCombination::__construct | ( | DoliDB | $db | ) |
Constructor.
Definition at line 101 of file ProductCombination.class.php.
Copies all product combinations from the origin product to the destination product.
User | $user | Object user |
int | $origProductId | Origin product id |
Product | $destProduct | Destination product |
Definition at line 937 of file ProductCombination.class.php.
References createProductCombination(), and fetchAllByFkProductParent().
ProductCombination::countNbOfCombinationForFkProductParent | ( | $fk_product_parent | ) |
Retrieves all product combinations by the product parent row id.
int | $fk_product_parent | Id of parent product |
Definition at line 331 of file ProductCombination.class.php.
References getEntity().
ProductCombination::create | ( | $user | ) |
Creates a product attribute combination.
User | $user | Object user |
Definition at line 353 of file ProductCombination.class.php.
References getDolGlobalString(), and saveCombinationPriceLevels().
ProductCombination::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.
Check usages to find more about its use Format of $combinations array: array( 0 => array( attr => value, attr2 => value [...] ), [...] )
User | $user | Object user |
Product | $product | Parent product |
array | $combinations | Attribute and value combinations. |
array | $variations | Price and weight variations |
bool | array | $price_var_percent | Is the price variation a relative variation? |
bool | float | $forced_pricevar | If the price variation is forced |
bool | float | $forced_weightvar | If the weight variation is forced |
bool | string | $forced_refvar | If the reference is forced |
string | $ref_ext | External reference |
If there is an existing combination, then we update the prices and weight Otherwise, we try adding a random number to the ref
Definition at line 716 of file ProductCombination.class.php.
References getDolGlobalString(), and price2num().
Referenced by copyAll().
ProductCombination::delete | ( | User | $user | ) |
Deletes a product combination.
User | $user | Object user |
Definition at line 425 of file ProductCombination.class.php.
ProductCombination::deleteByFkProductParent | ( | $user, | |
$fk_product_parent ) |
Deletes all product combinations of a parent product.
User | $user | Object user |
int | $fk_product_parent | Rowid of parent product |
Definition at line 456 of file ProductCombination.class.php.
References fetchAllByFkProductParent().
ProductCombination::fetch | ( | $rowid | ) |
Retrieves a combination by its rowid.
int | $rowid | Row id |
Definition at line 115 of file ProductCombination.class.php.
References fetchCombinationPriceLevels(), getDolGlobalString(), and getEntity().
ProductCombination::fetchAllByFkProductParent | ( | $fk_product_parent | ) |
Retrieves all product combinations by the product parent row id.
int | $fk_product_parent | Rowid of parent product |
Definition at line 289 of file ProductCombination.class.php.
References getDolGlobalString(), and getEntity().
Referenced by copyAll(), and deleteByFkProductParent().
ProductCombination::fetchByFkProductChild | ( | $productid, | |
$donotloadpricelevel = 0 ) |
Retrieves information of a variant product and ID of its parent product.
int | $productid | Product ID of variant |
int | $donotloadpricelevel | Avoid loading price impact for each level. If PRODUIT_MULTIPRICES is not set, this has no effect. |
Definition at line 250 of file ProductCombination.class.php.
References fetchCombinationPriceLevels(), getDolGlobalString(), and getEntity().
ProductCombination::fetchByProductCombination2ValuePairs | ( | $prodid, | |
array | $features ) |
Retrieves the combination that matches the given features.
int | $prodid | Id of parent product |
array | $features | Format: [$attr] => $attr_val |
Definition at line 613 of file ProductCombination.class.php.
ProductCombination::fetchCombinationPriceLevels | ( | $fk_price_level = 0, | |
$useCache = true ) |
Retrieves combination price levels.
int | $fk_price_level | The price level to fetch, use 0 for all |
bool | $useCache | To use cache or not |
for auto retrocompatibility with last behavior
Definition at line 156 of file ProductCombination.class.php.
References ProductCombinationLevel\createFromParent().
Referenced by fetch(), and fetchByFkProductChild().
ProductCombination::getCombinationLabel | ( | $prod_child | ) |
Return label for combinations.
int | $prod_child | id of child |
Definition at line 979 of file ProductCombination.class.php.
Referenced by updateProperties().
ProductCombination::getUniqueAttributesAndValuesByFkProductParent | ( | $productid | ) |
Retrieves all unique attributes for a parent product.
int | $productid | Product rowid |
Definition at line 654 of file ProductCombination.class.php.
ProductCombination::saveCombinationPriceLevels | ( | $clean = 1 | ) |
Retrieves combination price levels.
int | $clean | Levels of PRODUIT_MULTIPRICES_LIMIT |
Definition at line 204 of file ProductCombination.class.php.
ProductCombination::update | ( | User | $user | ) |
Updates a product combination.
User | $user | Object user |
Definition at line 389 of file ProductCombination.class.php.
References getDolGlobalString(), saveCombinationPriceLevels(), and updateProperties().
Updates the weight of the child product.
The price must be updated using Product\updatePrices. This method is called by the update() of a product.
Definition at line 491 of file ProductCombination.class.php.
References getCombinationLabel(), and getDolGlobalString().
Referenced by update().