• v3.2
    • Versions
    • v3.2

 

  • Install Akeneo PIM
    • Install Akeneo PIM with Docker
    • Install Akeneo PIM manually
      • System Requirements
      • System installation on Debian 9 (Stretch)
      • System installation on Ubuntu 16.04 (Xenial Xerus)
      • Installing Akeneo PIM Community Edition (CE) with the Archive
      • Installing Akeneo PIM Enterprise Edition (EE) with the Archive
      • Setting up the job queue daemon
    • How to customize the Dataset
    • How to Add Translation Packs
  • Migrate Akeneo PIM projects
    • How to apply a patch?
      • How to apply a patch - Community Edition
      • How to apply a patch - Enterprise Edition - Flexibility Cloud offer
      • How to apply a patch - Enterprise Edition - On Premise offer
    • Where is the Changelog?
    • How to upgrade to a minor version?
    • How to upgrade to a major version?
  • Import and Export data
    • How import works
    • Understanding the Product Import
    • Understanding the Product Export
    • Formats
      • Localized labels
      • Scopable labels
      • Association types data structure
      • Attribute data structure
      • Category data structure
      • Family data structure
      • Family variant data structure
      • Group data structure
      • Options data structure
      • Product data structure
      • Product model data structure
    • Akeneo Connectors
    • How to Customize Import / Export
      • How to create a new Connector
      • How to import Products from a XML file
      • How to clean a CSV file during a Product import
      • How to automate imports/exports
  • Manipulate the Akeneo PIM data
    • How to Customize Mass Edit Operations
      • How to register a new bulk action
      • How to Register a New Mass Edit Action on Products
      • How to Avoid Rules Execution on Mass Edit Actions
    • How to Manipulate Products
      • How to Query Products
      • How to Create Products
      • How to Update Products
      • How to Validate Products
      • How to Save Products
      • How to Remove Products
    • How to Manipulate Non-Product Objects
      • How to Query Non-Product Objects
      • How to Create Non-Product Objects
      • How to Update Non-Product Objects
      • How to Validate Non-Product Objects
      • How to Save Non-Product Objects
      • How to Remove Non-Product Objects
    • How to add a custom action rule
      • General information about rule format
      • How to add a custom action in the rule engine
    • How to Define Access Control List
    • How to Customize the Catalog Structure
      • How to Create a Reference Data
      • How to add a custom unit of measure
      • How to Add New Properties to a Category
    • How to Customize Product Assets
      • How to Add a New Transformation
      • How to Add a Default Thumbnail For Unknown File Types
      • How to connect to an external server for storage
      • How to change the validation rule to match a reference file to an asset
      • How to Mass Import Assets
    • How To Customize Teamwork Assistant (Enterprise Edition)
      • Customize notifications
      • Add a calculation step
      • How to log calculation step
      • Remove projects impacted by a custom catalog update
  • Design the user interfaces
    • How to customize any frontend part of the application
    • How to add an action button or meta data to the product edit form
    • How to add a tab to a form
    • How to add a new tab in System / Configuration
    • How to add custom information to a field
    • How to add a new field type
    • Create a custom product export builder filter
    • How to create the UI to manage a Reference Data
    • How to add a new page
    • How to customize the main menu
    • Styleguide
  • Maintain Akeneo PIM projects
    • First aid kit
    • Bug qualification
    • Common issues
    • Scalability Guide
      • Audit with 3 Representative Catalogs
      • More than 10k attributes?
      • More than 10k families?
      • More than 10k categories?
      • More than 500 attributes usable in the product grids?
      • More than 100k products to export?
      • More than 1GB of product media to export?
    • How to purge history
      • How to Purge jobs executions
      • How to adapt the version purger to your needs
  • Contribute to Akeneo PIM
    • How to report an issue?
    • How to translate the user interface?
    • How to enhance the documentation?
    • How to contribute to a Connector?
    • How to submit a patch to the PIM?
    • How to contribute to the frontend part of the application
    • How behavior tests are architectured in the PIM?
      • Establishing Decorator Pattern
      • Using Spin In Behat
  • Use SSO authentication locally
  • Reference Entities (beta)
    • Configure Entity Limits
    • Create a new Reference Entity Attribute type
    • Enrich Records with a new Reference Entity Attribute type
    • Add a Custom Property to Your Custom Attribute Type
    • Refresh records completeness
  • Technical overview
    • Product Information
    • Teamwork Assistant (Enterprise Edition)
      • Project creation
      • Project completeness
      • Project Completeness widget
      • Catalog update impact
      • Scalability guide
      • Users permission summary for Behat tests
    • Collaborative workflow
      • Simple workflow
      • Partial workflow
  • Technical architecture
    • Best Practices
      • Create a project
      • Create a reusable bundle
      • Setup Behat
      • Code Conventions
      • Coding Standards
    • How to implement your business logic using the event system
    • Events
      • Storage events
      • Workflow events (Enterprise Edition only)
    • How to Localize your data
      • How to change the PIM locale
      • How to Use Localizers
      • How to use Presenters
    • How to Add a Notification
    • Performances Guide
      • Memory usage of rules execution (Enterprise Edition)
      • Memory leak fix in Rules Engine (ORM)
      • More than 100 WYSIWYG editors in a page
      • PHP7 and HHVM Compatibility?
      • Job product batch size
    • How to Use the Web REST API
    • Standard format
      • Products
      • Other entities
      • Usage
    • Application Technical Information
      • Application Technical Dependencies
      • Server side set up for hosting
      • System Requirements
      • Recommended configuration
      • Client side configuration and compatibilities
      • Operation processes
      • Flow Matrix
  • Akeneo Cloud Edition
    • Flexibility Mode
      • Overview
      • Partners Starterkit
      • Environments Access
      • Composer settings
      • Periodic tasks / Crontab settings
      • PIM Application
      • PIM Updates and Migrations
      • File Transfer (SFTP)
      • Backups management
      • Partners
      • Queue management
      • System Components
      • Disk Usage
      • Ensure the Onboarder worker is always running
    • Serenity Mode
      • Overview
      • PIM Updates and Migrations
  • Akeneo Onboarder
    • Prerequisites
    • Installation
    • Migrate Akeneo Onboarder projects
      • How to apply a patch?
        • How to apply an Onboarder patch - Enterprise Edition - Flexibility Cloud offer
        • How to apply an Onboarder patch - Enterprise Edition - On Premise offer
      • How to upgrade to a minor version?
      • How to upgrade to a major version?
    • Synchronization
    • Troubleshooting
    • Environment variables
      • Using the DotEnv file
      • Using environment variables

General information about rule format¶

Quick Overview¶

This cookbook is about a feature only provided in the Enterprise Edition.

Enrichment rules allow to set values for products given specific conditions. These rules can be manually applied from the User Interface or run using a cronjob.

File Structure¶

Enrichment rules are defined in YAML format, so the file extension has to be “.yml”. Indentation is mandatory within the file and has to follow the YAML format strictly. You have to import a rule so that it can be used in the PIM.

This file starts with “rules” root element, which contains the list of enrichment rules. This document is about this list. Each rule is referred to by a code and can contain a list of conditions and actions.

# Example of a file with 2 rules
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
    camera_copy_name_to_model:
        priority: 0
        conditions:
            - field: family
              operator: IN
              value:
                - camcorders
            - field: camera_model_name
              operator: EMPTY
        actions:
            - type: copy
              from_field: name
              to_field: camera_model_name

Indentation is mandatory within the file and must be strictly identical to the one shown in the example.

Enrichment Rule Structure¶

Structure’s elements which define a rule are:
  • rule’s code (dynamic)*
  • priority
  • conditions*
  • actions*
Structure’s elements which define a condition are:
  • field*
  • locale
  • scope
  • operator*
  • value*

An enrichment rule is structured as follow:

[free rule code]:
    priority*:
    conditions:
        - field*:
          locale:
          scope:
          operator*:
          value*:
    actions:
        - type:*
          [Diverse elements according to the action]

Elements with * are mandatory. Fill in the locale and scope elements only if your condition applies on localizable and/or scopable attributes.

Dashes (-) must be placed before an element field and after each element contained in value part.

Colon (:) mandatory after each structure element.

Tip

For more details you can see the YAML specifications.

Warning

Rules code choice is up to you, however it has to contain only alphanumeric characters, underscores, dashes and be less than 255 characters.

A priority can be given to a rule. Priority will be considered for rules execution order. Without any given priority, rule has a zero-priority. The higher the priority, the sooner the rule will be executed. Therefore, a rule with 90-priority will be executed before rules with a 0-priority. If no rule has defined priority, they will be executed in a “technical” order. (database reading order)

Action’s conditions can be applied on localizable and scopable values. In this case, it has to be specified using and scope elements.

The definition of conditions is very important, make sure you select only products concerned by the rule. Add conditions so the rule(s) will not be executed if needed.

  • The field “camera_brand” will be updated only if its value is not already equal to “canon_brand”.
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
  • The field “auto_focus_points” will be updated only if its value is not already equal to “4”.
rules:
    camera_set_autofocus_point:
        priority: 0
        conditions:
            - field: family
              operator: IN
              value:
                - camcorders
            - field: name
              operator: CONTAINS
              value: Canon
            - field: auto_focus_points
              operator: !=
              value: 4
        actions:
            - type: set
              field: auto_focus_points
              value: 4
  • The field “description” for en_US locale and ecommerce channel will be updated only if its value is EMPTY and if the source field “description” for en_US locale and print channel is NOT EMPTY.
rules:
    copy_description_us_to_ecommerce_us:
        priority: 0
        conditions:
            - field: family
              operator: IN
              value:
                - camcorders
            - field: description
              locale: en_US
              scope: ecommerce
              operator: EMPTY
            - field: description
              locale: en_US
              scope: print
              operator: NOT EMPTY
        actions:
            - type: copy
              from_field: description
              to_field: description
              from_locale: en_US
              from_scope: print
              to_locale: en_US
              to_scope: ecommerce

Enrichment Rule Definition¶

Available Actions List¶

Akeneo rules engine proposes 4 kinds of actions:

Copy¶

This action copies an attribute value into another.

Warning

Source and target attributes should share the same type. If the source attribute is empty, the value “empty” will also be copied.

Two parameters are required while the four others are optional:
  • from_field: code of the attribute to be copied.
  • from_locale: locale code of the value to be copied (optional).
  • from_scope: channel code of the value to be copied (optional).
  • to_field: attribute code the value will be copied into.
  • to_locale: locale code the value will be copied into (optional).
  • to_scope: channel code the value will be copied into (optional).

Tip

For instance, you have a scopable and localizable attribute called “description”, you can copy its content from en_US locale and print channel to the en_US locale and ecommerce channel. Action will be defined as follows:

actions:
    - type:        copy
      from_field:  description
      from_locale: en_US
      from_scope:  print
      to_field:    description
      to_locale:   en_US
      to_scope:    ecommerce

Set¶

This action assigns value(s) to an attribute having the type text, textArea, simple select…

Two parameters are required while the two others are optional.
  • field: attribute code.
  • locale: locale code for which value is assigned (optional).
  • scope: channel code for which value is assigned (optional).
  • value: attribute value.

Tip

For instance, to set the value “My very new description for purple tshirt” to your description attribute in en_US locale, for ecommerce channel, the action will be as follows:

actions:
    - type:   set
      field:  description
      locale: en_US
      scope:  ecommerce
      value:  "My very new description for purple tshirt"

Add¶

This action allows to add values to a multi-select attribute, a reference entity multiple links attribute or a product to categories.

Two parameters are required while the two others are optional.
  • field: attribute code.
  • locale: locale code for which value is assigned (optional).
  • scope: channel code for which value is assigned (optional).
  • items: attribute values to add.

Tip

For instance, to add the category “t-shirts”, action will be as follows:

actions:
    - type: add
      field: categories
      items:
        - t-shirts

Remove¶

This action removes values from a multi-select attribute, a reference entity multiple links attribute or a product category.

Two parameters are required while the three others are optional.
  • field: attribute code or “categories”.
  • locale: locale code for which value is assigned (optional).
  • scope: channel code for which value is assigned (optional).
  • items: values to remove.
  • include_children: if true, then also apply the removal of the children to the given categories. Only applicable if field is set to “categories” (optional, defaults to false).

Tip

For instance, to remove the category “t-shirts”, action will be as follows:

actions:
    - type: remove
      field: categories
      items:
        - t-shirts

To remove the category “clothing” and its children, action will be as follows:

actions:
    - type: remove
      field: categories
      items:
        - clothing
      include_children: true

To unclassify products from the whole “Master catalog” tree, action will be as follows:

actions:
    - type: remove
      field: categories
      items:
        - master
      include_children: true

Warning

In order to fully unclassify a product (i.e. remove all its categories, from every category tree), it is far more efficient to use a set action:

actions:
    - type: set
      field: categories
      value: []

Fields¶

Created¶

Operator
  • =
  • !=
  • “>”
  • <
  • BETWEEN
  • NOT BETWEEN
  • EMPTY
  • NOT EMPTY
Value date format: yyyy-mm-dd. If operator is EMPTY or NOT EMPTY, value element will be ignored.
Example
field: created
operator: =
value: "2015-01-23"

Updated¶

Operator
  • =
  • !=
  • “>”
  • <
  • BETWEEN
  • NOT BETWEEN
  • EMPTY
  • NOT EMPTY
Value date format: yyyy-mm-dd. If operator is EMPTY or NOT EMPTY, value element will be ignored.
Example
field: updated
operator: =
value: "2015-01-23"

Enabled¶

Operator
  • =
  • !=
Value activated => “true” deactived => “false”
Example
field: enabled
operator: =
value: false

Completeness¶

Operator
  • =
  • !=
  • “>”
  • <
Value Percentage. /!\ locale and scope elements are mandatory.
Example
field: completeness
locale: fr_FR
scope: print
operator: =
value: "100"

Family¶

Operator
  • IN
  • NOT IN
  • EMPTY
  • NOT EMPTY
Value Family code. If operator is EMPTY or NOT EMPTY, value element will be ignored.
Example
field: family
operator: IN
value:
 - camcorders
 - digital_cameras

Groups¶

Operator
  • IN
  • NOT IN
  • EMPTY
  • NOT EMPTY
Value Group code. If operator is EMPTY or NOT EMPTY, value element will be ignored.
Example
field: groups
operator: IN
value:
 - oro_tshirts
 - akeneo_tshirts

Categories¶

Operator
  • IN
  • NOT IN
  • UNCLASSIFIED
  • IN OR UNCLASSIFIED
  • IN CHILDREN
  • NOT IN CHILDREN
Value Category code
Example
field: categories
operator: IN
value:
 - C0056
 - F677

Attribute Types¶

Text / Textarea¶

Operator
  • STARTS WITH
  • ENDS WITH
  • CONTAINS
  • DOES NOT CONTAIN
  • =
  • !=
  • EMPTY
  • NOT EMPTY
Value Text, with or without quotation marks. If operator is EMPTY or NOT EMPTY, value element will be ignored.
Example
field: description
operator: CONTAINS
value: "Awesome product"

Metric¶

Operator
  • <
  • <=
  • =
  • !=
  • “>”
  • “>=”
  • EMPTY
  • NOT EMPTY
Value Numeric value and measure unit code. Dot “.” is the decimal separator. No space between thousands. If operator is EMPTY or NOT EMPTY, value element will be ignored.
Example
field: weight
operator: =
value:
 amount: 0.5
 unit: KILOGRAM

Boolean¶

Operator
  • =
  • !=
Value Yes => “true” No => “false”
Example
field: shippable_us
operator: =
value: false

Simple select list / Reference entity single link¶

Operator
  • IN
  • NOT IN
  • EMPTY
  • NOT EMPTY
Value Option code. If operator is EMPTY or NOT EMPTY, value element will be ignored. NOT IN (red, blue) means != red and != blue.
Example
field: size
operator: IN
value:
 - xxl

Multiselect List / Reference entity multiple links¶

Operator
  • IN
  • NOT IN
  • EMPTY
  • NOT EMPTY
Value Option code. If operator is EMPTY or NOT EMPTY, value element will be ignored. NOT IN (red, blue) means != red and != blue.
Example
field: material
operator: IN
value:
 - GOLD
 - LEATHER

Number¶

Operator
  • <
  • <=
  • =
  • !=
  • “>”
  • “>=”
  • EMPTY
  • NOT EMPTY
Value Number. If operator is EMPTY or NOT EMPTY, value element will be ignored.
Example
field: min_age
operator: =
value: 12

Date¶

Operator
  • <
  • “>”
  • =
  • !=
  • BETWEEN
  • NOT BETWEEN
  • EMPTY
  • NOT EMPTY
Value Format date: yyyy-mm-dd. If operator is EMPTY or NOT EMPTY, values information is ignored.
Example
field: created_date
operator: ">"
value: "2016-05-12"

Price¶

Operator
  • <
  • <=
  • =
  • !=
  • “>”
  • “>=”
  • EMPTY
  • NOT EMPTY
Value Numeric value and currency code. Dot “.” is the decimal separator. No space between thousands. If operator is EMPTY or NOT EMPTY, value element will be ignored.
Example
field: basic_price
operator: <=
value:
  amount: 12
  currency: EUR

field: null_price
operator: NOT EMPTY
value:
  amount: null
  currency: EUR

Picture or file¶

Operator
  • STARTS WITH
  • ENDS WITH
  • CONTAINS
  • DOES NOT CONTAIN
  • =
  • !=
  • EMPTY
  • NOT EMPTY
Value Text. If operator is EMPTY or NOT EMPTY, value element will be ignored.
Example
field: small_image
operator: CONTAINS
value: ../../../
 src/PimEnterprise/Bundle/
 InstallerBundle/Resources/
 fixtures/icecat_demo/images/
 AKNTS_PB.jpg

Found a typo or a hole in the documentation and feel like contributing?
Join us on Github!