<<

NAME

ProductOpener::ForestFootprint2026 - compute the forest footprint of a food product using the 2026 algorithm

SYNOPSIS

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.

DESCRIPTION

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

FUNCTIONS

load_forest_footprint_2026_data ()

Loads data needed to compute the forest footprint using the 2026 algorithm.

compute_forest_footprint_2026 ( $product_ref )

compute_forest_footprint_2026() computes the forest footprint of a food product using the 2026 algorithm, and stores the details of the computation.

Arguments

Product reference $product_ref

Return values

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 ( $product_ref, $ingredient_ref )

get_forest_footprint_2026_ingredient_footprint() computes the forest footprint for a single ingredient.

Arguments

Product reference $product_ref

Used to determine labels and origins for risk factor.

Ingredient reference $ingredient_ref

The ingredient to compute the footprint for.

Return values

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 ($product_ref, $ingredient_ref, $primary_ingredient_id)

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.

get_label_risk_data ($product_ref, $ingredient_ref, $primary_ingredient_id)

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)

calculate_forest_footprint_2026_grade ($product_ref)

calculate_forest_footprint_2026_grade() calculates the forest footprint grade for a product.

Grades: - a: Best (lowest environmental impact) - d: Worst (highest environmental impact)

<<