What is a rule?

Summary

Definition of a rule

A rule is a set of actions and conditions that allows you to automatize data enrichment. For instance, rules allow you to automatically:

  • fill in attributes
  • categorize new products
  • set a default value to an empty attribute
  • assign values to new products
  • copy an attribute value to another attribute

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 with a priority of 10, but it will be applied after a rule with a priority of 500.

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.

 

How can we improve this article?

Share additional info and suggestions