Manage your rules

Summary

Overview

A rule allows you to enrich some of your product information automatically. It relies on automatic actions based on conditions. A rule is composed of one or several conditions that allow you to filter products/product models and then one or several actions to update these products/product models.
For more details, please refer to our dedicated article about the rules engine.

To create a rule, there are two options. Either you create it via the UI or a YML import job.

Create a rule in the PIM UI

To be able to create/edit rules, you need to have the right permissions. To manage your permissions, please go to System/Roles, select the appropriate role, click on Permissions/Rules, and tick Create rules and/or Edit rules.

 

To create a rule via the UI, go to Settings/Rules and click on Create. A creation pop-in appears. Choose a code and a label to name your rule, then validate. Your rule is created! You can now define your product selection and the action.s you want to apply to your selection. Let's go!

Once your rule is created, the rule edit screen appears. You can see two tabs on this screen: the rule builder and properties. In the Properties tab, you can define the priority of your rule and its labels' translations. These fields can be updated afterward. The code is the only part that is immutable.

The rule builder tab

This screen is the most important one as this is where you can manage your conditions and actions.

The first thing to do is to filter the products you want to update with this rule. To do so, many filters are available under the Add condition button.

Product selection

In the Product selection part, you can define the 'Conditions'. They are the attributes or system fields you want to filter your products/product models. Altogether, your Conditions will create your 'Product selection'.

If you want to know the entire list of attributes/system fields, look at our article.

 

When there is no condition, your whole product catalog is selected by default. So if you add one or several actions, your whole catalog will be updated.

 

You will find the system fields at the top of the list and, below, all the attributes gathered by attribute groups. There is a search bar to help you find the attributes. Each time you add a condition, its color turns purple to inform you that it is already used. A new line appears in the product selection.

Let's see how a line is organized.

You will find the system fields or attribute you chose on the left. It is written in purple. Then, you have to choose an operator. Depending on the filter, the operator list changes. The next fields vary depending on your filter. There can be up to 3 types of fields. You can have the value field. For example, if your filter is a multi-select attribute type, you can choose which options to filter.

If your filter has a value per channel and/or per locale, the channel and locale fields appear to let you choose which locale/channel you want to filter on.

If you want to remove a condition, click on the cross at the end of the line.

As you can see on the left side of the Add condition button, there is a counter that tells you how many products/product models will be updated by this rule. It means that these conditions will impact X products/product models. This count is automatically updated as soon as you change a condition.

Available conditions

To select your products/product models, you can use all the system fields and attribute types of the PIM as conditions:

  • Categories
  • Family
  • Family variant
  • Groups
  • Status
  • Entity type (product or product model)
  • Identifier
  • Completeness
  • Parent
  • Creation date
  • Update date
  • Asset collection attribute
  • Date attribute
  • File attribute
  • Image attribute
  • Measurement attribute
  • Multi select attribute
  • Simple select attribute
  • Number attribute
  • Text attribute
  • Boolean attribute
  • Text area attribute
  • Reference entity single link & multiple link attributes
  • Price attribute
  • Table attribute

Add actions

Now that you have filtered your products/product models, you can add one or several actions you'll apply to them!

To do so:

  1. Click on Add action at the top of the screen
  2. Select the action you want to add. There is a search bar and a scroll bar to choose the action from a list.
  3. A new section appears under the Product selection part.

Here is the list of all the actions you can do with the rules engine if you use the YML file import.

Depending on the action you choose, the template changes. The table below lists all the actions that you can add via the PIM interface.

Available actions

Set actions What they do
Set categories Classify your products/product models in your chosen categories, and remove them from their former categories.
Set family Replace your products' families.
Set attribute value Set values to any attribute type. It will replace the former values.
Set groups Set groups to your product selection (product models don't have groups);
Set associations Set associations to your product/product model selection (you can choose the association type and the entity you want to associate with: products, product models, or groups).
Set quantified associations Set quantified associations to your product/product model selection (you can choose the association type and the entity you want to associate with: products, product models or groups, and finally, their quantity).
Set status Set a status to your product selection.
Add actions What they do
Add categories Classify your products/product models in new categories, without removing them from their former categories.
Add groups Add groups to your product selection (product models don't have groups).
Add attribute value Add values to a multi select, a price collection, a reference entity multiple links, or an asset collection attribute. It will keep the former values.
Add associations Add associations to your product/product model selection (you can choose the association type and the entity you want to associate with: products, product models, or groups).
Remove actions What they do
Remove categories Unclassify your product/product model selection from the chosen categories.
Remove products from groups Remove your product selection from groups (product models don't have groups).
Remove attribute values Remove values from a multi-select, a reference entity multiple links, or an asset collection attribute.
Clear actions What they do
Clear attribute value Delete values from an attribute on your product/product models selection.
Clear associations Delete all the associations of your product/product models selection.
Clear quantified associations Delete all the quantified associations of your product selection.
Clear groups Delete all the groups of your product selection (product models don't have groups).
Clear categories Unclassify your product/product model selection from every category.
Copy action What it does
Copy attribute value Copy the value from an attribute to another one.
Calculate action What it does
Calculate attribute value Calculate numeric attribute values, with simple mathematical operations.
Concatenate action What it does
Concatenate attribute value Concatenate at least two values into a single value. You can use this action to create a description for instance, using free text fields, attribute fields and line breaks.

Create rules via a YML import

To create rules using a YML file, you need to create it and import it in the PIM using the Rule import in YML import job.

For more details about how to execute an import, please refer to Import your data.

 

You can also export your rules. For that, execute the Rule export in YML export job. For more details about executing an export, please refer to Export your data.

 

View all rules

The Settings/Rules screen displays a grid with all the rules created and imported in the PIM.
You can search on the rule code or label.

In the last column, there is a tag. Thanks to these tags, you can see at a glance the action type behind each rule (add, copy, concatenate, set, calculate, remove, clear) 😉

You can order your rules by priority.

Calculate the number of impacted products per rule

To help you define and validate the conditions for your rules and validate them, you can calculate the number of matching products the rule will process.

The first time a rule is executed, it can match many products. The following time, you might have zero impacted products or only a few.

  1. To use this action, select one or several rules by ticking them on the left side of the screen
  2. Click on Calculate the impacted products
  3. Then confirm the action in the pop in
  4. A flash message confirming the action will be displayed, and you will be notified once the calculation is done.

The number of impacted products will appear on the right side of your screen in the Impacted products column.

Execute rules

Rules are automatically executed 4 times a day: at 5 am UTC, at 11 am UTC, at 5 pm UTC and at 11 pm UTC. Rules are also regularly executed after a bulk action or after imports with rules.

When using imports with rules, products without identifiers and UUIDs will be skipped during rule execution. This means:

  • Rules will be applied immediately after import for all products that have either identifiers or UUIDs.
  • For products that were skipped due to the lack of identifiers or UUIDs, rules will be executed four times a day, similar to the process for a 'classic' import.
 

But you can also execute rules on your own. You can execute the following:

  • sub-productone specific rule
  • a selection of rules
  • all your rules (be aware, this action could take a long time)

The rules support product models, so rules can also be defined on attributes at the product model level (or sub product model level).

 

The rules execution summary is accessible via the process tracker.

In this summary, you can easily access the details of the execution: how many rules were executed, how many products/product models were updated, warnings...

In order to access the summary of nightly scheduled rules (by cron), you need to have the right to View all jobs in process tracker in the Roles permissions to be able to see them in the process tracker 😉.

 

Execute a single rule

To execute a rule, click Execute at the end of each line in the grid.
A confirmation message validates the action of executing a rule.

If you are editing/creating a rule in the rule edit form, you can execute it by clicking on ... then Save and execute.

Execute a selection of rules

You can also execute several rules at the same time:

  1. Select one or several rules by ticking them on the left side of the screen
  2. Click on Execute
  3. Then confirm the action in the pop in
  4. A flash message confirming the action will be displayed, and you will be notified once the execution is done

Define a status for a rule

Sometimes, you may need to create/update a rule and save it but not execute it automatically because you will need to finetune it later. To do so, you can use the Status property.

To change the status, click on the Properties tab of a rule and choose between Enabled or Disabled.

You can see at a glance the status of each rule in the rules grid.

By default, each new rule you create via the UI is disabled.

 

Duplicate a rule

For instance, you have very similar rules with only one different condition. To avoid re-writing the whole rule, you can duplicate it.

To duplicate a rule, access the rule edit form, click on, then Save and duplicate. The creation pop-in opens, and you can choose a code and a label for your new rule.

By default, when you duplicate a rule, it is disabled. To execute it, you have to change its status, under the Properties tab of the rule.

 

Delete rules

The rules engine can no longer execute a deleted rule. The products keep the values calculated by the deleted rule.

 

Delete a single rule

To delete a rule, click Delete at the end of each line in the grid.
A confirmation message validates the action of deleting a rule.

If you do not see the Delete button, it might be because you do not have the right permissions. Please refer to Manage your user roles.

 

Delete a selection of rules

You can also delete several rules at the same time:

  1. Select one or several rules by ticking them on the left side of the screen
  2. Click on Delete
  3. Then, confirm the action in the pop-in.