dolibarr  7.0.0-beta
Public Member Functions | List of all members
ProductCombination Class Reference

Class ProductCombination Used to represent a product combination. More...

Public Member Functions

 fetch ($rowid)
 Retrieves a combination by its rowid. More...
 
 fetchByFkProductChild ($fk_child)
 Retrieves a product combination by a child product row id. More...
 
 fetchAllByFkProductParent ($fk_product_parent)
 Retrieves all product combinations by the product parent row id. More...
 
 countNbOfCombinationForFkProductParent ($fk_product_parent)
 Retrieves all product combinations by the product parent row id. More...
 
 create ($user)
 Creates a product attribute combination. More...
 
 update (User $user)
 Updates a product combination. More...
 
 delete (User $user)
 Deletes a product combination. More...
 
 deleteByFkProductParent ($fk_product_parent)
 Deletes all product combinations of a parent product. More...
 
 updateProperties (Product $parent)
 Updates the weight of the child product. More...
 
 fetchByProductCombination2ValuePairs ($prodid, array $features)
 Retrieves the combination that matches the given features. More...
 
 getUniqueAttributesAndValuesByFkProductParent ($productid)
 Retrieves all unique attributres for a parent product. More...
 
 createProductCombination (Product $product, array $combinations, array $variations, $price_var_percent=false, $forced_pricevar=false, $forced_weightvar=false)
 Creates a product combination. More...
 
 copyAll ($origProductId, Product $destProduct)
 Copies all product combinations from the origin product to the destination product. More...
 

Detailed Description

Class ProductCombination Used to represent a product combination.

Definition at line 23 of file ProductCombination.class.php.

Member Function Documentation

ProductCombination::copyAll (   $origProductId,
Product  $destProduct 
)

Copies all product combinations from the origin product to the destination product.

Parameters
int$origProductIdOrigin product id
Product$destProductDestination product
Returns
int >0 OK <0 KO

Definition at line 641 of file ProductCombination.class.php.

References createProductCombination(), and fetchAllByFkProductParent().

ProductCombination::countNbOfCombinationForFkProductParent (   $fk_product_parent)

Retrieves all product combinations by the product parent row id.

Parameters
int$fk_product_parentId of parent product
Returns
int Nb of record

Definition at line 185 of file ProductCombination.class.php.

References $resql, and getEntity().

ProductCombination::create (   $user)

Creates a product attribute combination.

Parameters
User$userObject user
Returns
int <0 if KO, >0 if OK

Definition at line 205 of file ProductCombination.class.php.

References float.

ProductCombination::createProductCombination ( Product  $product,
array  $combinations,
array  $variations,
  $price_var_percent = false,
  $forced_pricevar = false,
  $forced_weightvar = false 
)

Creates a product combination.

Check usages to find more about its use

Format of $combinations array: array( 0 => array( attr => value, attr2 => value [...] ), [...] )

Parameters
Product$productParent product
array$combinationsAttribute and value combinations.
array$variationsPrice and weight variations
bool$price_var_percentIs the price variation a relative variation?
bool | float$forced_pricevarIf the price variation is forced
bool | float$forced_weightvarIf the weight variation is forced
Returns
int <0 KO, >0 OK

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 479 of file ProductCombination.class.php.

References float, and price2num().

Referenced by copyAll().

ProductCombination::delete ( User  $user)

Deletes a product combination.

Parameters
User$userObject user
Returns
int <0 if KO, >0 if OK

Definition at line 257 of file ProductCombination.class.php.

ProductCombination::deleteByFkProductParent (   $fk_product_parent)

Deletes all product combinations of a parent product.

Parameters
int$fk_product_parentRowid of parent product
Returns
int <0 KO >0 OK

Definition at line 281 of file ProductCombination.class.php.

References fetchAllByFkProductParent().

ProductCombination::fetch (   $rowid)

Retrieves a combination by its rowid.

Parameters
int$rowidRow id
Returns
int <0 KO, >0 OK

Definition at line 87 of file ProductCombination.class.php.

References getEntity().

ProductCombination::fetchAllByFkProductParent (   $fk_product_parent)

Retrieves all product combinations by the product parent row id.

Parameters
int$fk_product_parentRowid of parent product
Returns
int|ProductCombination[] <0 KO

Definition at line 151 of file ProductCombination.class.php.

References getEntity().

Referenced by copyAll(), and deleteByFkProductParent().

ProductCombination::fetchByFkProductChild (   $fk_child)

Retrieves a product combination by a child product row id.

Parameters
int$fk_childProduct row id
Returns
int <0 KO, >0 OK

Definition at line 119 of file ProductCombination.class.php.

References getEntity().

ProductCombination::fetchByProductCombination2ValuePairs (   $prodid,
array  $features 
)

Retrieves the combination that matches the given features.

Parameters
int$prodidId of parent product
array$featuresFormat: [$attr] => $attr_val
Returns
false|ProductCombination False if not found

Definition at line 379 of file ProductCombination.class.php.

ProductCombination::getUniqueAttributesAndValuesByFkProductParent (   $productid)

Retrieves all unique attributres for a parent product.

Parameters
int$productidProduct rowid
Returns
ProductAttribute[]

Definition at line 417 of file ProductCombination.class.php.

ProductCombination::update ( User  $user)

Updates a product combination.

Parameters
User$userObject user
Returns
int <0 KO, >0 OK

Definition at line 230 of file ProductCombination.class.php.

References float, and updateProperties().

ProductCombination::updateProperties ( Product  $parent)

Updates the weight of the child product.

The price must be updated using Product::updatePrices

Parameters
Product$parentParent product
Returns
int >0 OK <0 KO

Definition at line 315 of file ProductCombination.class.php.

References Product\updatePrice().

Referenced by update().


The documentation for this class was generated from the following file: