What is a rule?

Summary

Definition of a rule

A rule is a set of conditions and actions that helps automate data enrichment and keep product data consistent at scale.

Rules can be used to automatically update product information when specific conditions are met. For instance, rules allow you to:

  • set or clear attribute values
  • add or remove values from multi-value attributes
  • copy values from one attribute to another
  • calculate numeric values
  • concatenate values
  • assign categories, families, groups, associations, or statuses
  • enrich products based on reference entity values
  • generate or translate attribute values with AI
  • generate dynamic content
  • apply default values to empty attributes
  • automate enrichment for new or existing products and product models

Depending on the type of data being enriched, rules can apply to product/product model data and, for supported use cases, record data as well.

A rule is defined by a code (required) and you can name it with a label as well. This label can have a value per locale.

Rules can only be created and imported in Akeneo using a YML file, but you can manage them from the UI. Check our How to manage your rules article.

Rules can be prioritized: a rule with a priority of 100 will be applied before a rule having a priority of 10 or 50.

Example of a rule

You need one or several conditions to trigger an action. For instance, to set the Canon brand to all Canon camcorders that do not have a brand yet, you'll have to create a rule like the one below:

IF:

  • my product is in the Camcorders family
  • my product attribute name contains the word: Canon
  • my brand attribute is empty

THEN: set the Canon value in my product brand attribute

Here is the example of the YML format expected for this rule.

rules:
            camera_set_canon_brand:
                priority: 0
                conditions:
                    -   field: family
                        operator: IN
                        value:
                            - camcorders
                    -   field: name
                        operator: CONTAINS
                        value: Canon
                    -   field: camera_brand
                        operator: 'NOT IN'
                        value:
                            - canon_brand
                actions:
                    -   type: set
                        field: camera_brand
                        value: canon_brand

Now that you know what a rule is, let's dive into this powerful feature! Discover in this article all the available conditions and actions, and learn how to use them.

You can refer to our technical documentation to find out more information about the rules engine.