ProductCombination
class ProductCombination (View source)
Class ProductCombination Used to represent the relation between a product and one of its variants.
Example: a product "shirt" has two variants "shirt XL white" and "shirt XL grey". This is represented with two ProductCombination objects:
- One for "shirt XL white":
- $object->fk_product_parent ID of the Product object "shirt"
- $object->fk_product_child ID of the Product object "shirt XL white"
- Another for "shirt XL grey":
- $object->fk_product_parent ID of the Product object "shirt"
- $object->fk_product_child ID of the Product object "shirt XL grey"
Properties
| DoliDB | $db | Database handler |
|
| int | $id | Rowid of this ProductCombination |
|
| int | $fk_product_parent | Rowid of the parent Product |
|
| int | $fk_product_child | Rowid of the variant Product |
|
| float | $variation_price | Price variation |
|
| bool|array | $variation_price_percentage | Is the price variation a relative variation? Can be an array if multiprice feature per level is enabled. |
|
| float | $variation_weight | Weight variation |
|
| int | $entity | Combination entity |
|
| ProductCombinationLevel[] | $combination_price_levels | Combination price level |
|
| string | $variation_ref_ext | External ref |
|
| string | $error | Error message |
|
| string[] | $errors | Array of error messages |
Methods
Retrieves a ProductCombination by its rowid
Retrieves combination price levels
Retrieves combination price levels
Retrieves information of a variant product and ID of its parent product.
Retrieves all product combinations by the product parent row id
Retrieves all product combinations by the product parent row id
Deletes all product combinations of a parent product
Updates the weight of the child product. The price must be updated using Product::updatePrices.
Retrieves the combination that matches the given features.
Retrieves all unique attributes for a parent product (filtered on its 'to sell' variants)
Creates a product combination. Check usages to find more about its use Format of $combinations array: array( 0 => array( attr => value, attr2 => value [...] ), [...] )
Return label for combinations
Details
__construct(DoliDB $db)
Constructor
int<-1, 1>
fetch(int $rowid)
Retrieves a ProductCombination by its rowid
int<-1, 1>
fetchCombinationPriceLevels(int $fk_price_level = 0, bool $useCache = true)
Retrieves combination price levels
int
saveCombinationPriceLevels(int $clean = 1)
Retrieves combination price levels
int
fetchByFkProductChild(int $productid, int $donotloadpricelevel = 0)
Retrieves information of a variant product and ID of its parent product.
int|ProductCombination[]
fetchAllByFkProductParent(int $fk_product_parent, bool $sort_by_ref = false)
Retrieves all product combinations by the product parent row id
int
countNbOfCombinationForFkProductParent(int $fk_product_parent)
Retrieves all product combinations by the product parent row id
int
create(User $user)
Creates a product attribute combination
int
update(User $user)
Updates a product combination
int
delete(User $user)
Deletes a product combination
int
deleteByFkProductParent(User $user, int $fk_product_parent)
Deletes all product combinations of a parent product
int
updateProperties(Product $parent, User $user)
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.
false|ProductCombination
fetchByProductCombination2ValuePairs(int $prodid, array $features)
Retrieves the combination that matches the given features.
ProductAttributeValue[]}>
getUniqueAttributesAndValuesByFkProductParent(int $productid)
Retrieves all unique attributes for a parent product (filtered on its 'to sell' variants)
int<-1, 1>
createProductCombination(User $user, Product $product, array $combinations, array $variations, bool|bool[] $price_var_percent = false, false|float|float[] $forced_pricevar = false, false|float $forced_weightvar = false, false|string $forced_refvar = false, string $ref_ext = '', bool $clone_categories = false)
Creates a product combination. Check usages to find more about its use Format of $combinations array: array( 0 => array( attr => value, attr2 => value [...] ), [...] )
int
copyAll(User $user, int $origProductId, Product $destProduct)
Copies all product combinations from the origin product to the destination product
string
getCombinationLabel(int $prod_child)
Return label for combinations