Formula ranking factor
The factor of the type formula calculates the sorting score based on the formula.
The syntax of the formula is the same as the syntax of spreadsheet formulas.
The formula should return a numeric result. Non-numeric results will be considered as NULL.
The formula SHOULD always start with =
.
Allowed variable types:
-
{product_[attribute_code]} - product attributes variable like {product_price}, {product_color}. Attributes of types gallery and media_image are not allowed in the formula.
Most common product attributes' variables:
- {product_price}
- {product_cost}
- {product_size}
- {product_color}
- {product_material}
- {product_brand}
- {factor_[id]} - ranking factors' variables. Products' rank can be calculated based on other factors in the factor of the type formula. The only restriction is - factors of the type formula can NOT be used in the factor of the type formula.
Examples:
={product_cost} / {product_weight}
- simple formula. This formula calculates the unit cost for each product.=IF({product_cost} > 50, 100, 0)
- formula with the condition.=IF({product_brand} = "Adidas", 100, 0)
- formula with the attribute of the type select.=IF(ISNUMBER(FIND("Gym", {product_activity})), 10, 1)
- formula with the attribute of the type multiselect.Note
When using attributes of the type multiselect the recommended formula isISNUMBER(FIND([needle], [variable]))
.
The partFIND([needle], [variable])
is responsible for searching needle in the variable's value. If the needle is not found theFIND()
function returns #VALUE! which makes theIF()
function return the same.
The #VALUE! value will be considered as NULL.
For making this formula work as expected theFIND()
function should be wrapped inISNUMBER()
function. In this case, the whole formula will return correct results.