ProductOpener::ForestFootprint2026 - compute the forest footprint of a food product using the 2026 algorithm
ProductOpener::ForestFootprint2026 is used to compute the forest footprint of a food product using the new 2026 algorithm based on direct ingredient-to-primary-ingredient mapping.
The module implements a new forest footprint computation algorithm that differs from the original ForestFootprint module. Instead of using soy-based calculations, it uses:
- Direct ingredient-to-ingredient_category mapping with equivalence factors - Ingredient_category to primary_ingredient mapping with equivalence factors - Origin-based footprint values for each primary ingredient (cocoa, coffee, palm-oil) - Label-based risk reduction percentages
The computation formula is: footprint = percent_estimate * equivalence_ingredient * equivalence_ingredient_category * origin_footprint * risk_factor
Loads data needed to compute the forest footprint using the 2026 algorithm.
compute_forest_footprint_2026() computes the forest footprint of a food product using the 2026 algorithm,
and stores the details of the computation.
The forest footprint and computations details are stored in the product reference passed as input parameter.
Returned values:
- forest_footprint_2026 : forest footprint computation details
get_forest_footprint_2026_ingredient_footprint() computes the forest footprint for a single ingredient.
Used to determine labels and origins for risk factor.
The ingredient to compute the footprint for.
Returns a reference to a hash containing the footprint details, or undef if the ingredient does not have a forest footprint.
get_origin_footprint_data() retrieves the origin footprint data for a given primary ingredient.
The origin can be specified in the ingredient's origins field or in the product's origins_tags. If no origin is found, the en:unknown origin is used.
If multiple origins are specified, we keep the one with the highest footprint for the given primary ingredient.
Determines if an ingredient has a label that reduces its risk factor, and returns the lowest risk factor among the labels. Input risk factors are in % (100% means the label does not reduce the risk, 0% means the label completely eliminates the risk).
Labels can be product wide labels (in labels_tags), or ingredients specific labels (stored in the "labels" field for each ingredient in the ingredients structure)
Used to determine product-wide labels for risk factor.
The primary ingredient to check labels for.
Used to determine ingredient-specific labels for risk factor.
calculate_forest_footprint_2026_grade() calculates the forest footprint grade for a product.
Grades: - a: Best (lowest environmental impact) - d: Worst (highest environmental impact)