How to add a validation rule to an attribute

This page is for administrators: the operations described require access to the administration area.

Set the checks that a product attribute must pass for each channel type. You need access to the Attributes administration area and the Can edit all fields user permission. The rules model is described in How validation works.

  1. In the menu, select Admin, then Attributes, and choose the entity type in Entity.
  2. In the attribute's row, click the Validation Rules icon. The attribute's rules page opens, with its type shown below the title.
  3. To group issues for this attribute, choose a class in Validation Error Class. Leave Any selected to assign no class.
  4. Find the section for the channel type. Each channel type has its own section, headed with its key and name.
  5. In Validation Type, choose Error or Warning.
  6. Set the checks, such as Required. The available checks depend on the attribute type and are described on each type's page, starting from Attribute types: for many types, the other checks only apply when Required is selected.
  7. Repeat steps 5 and 6 for the other channel types where the attribute needs to be checked. A channel type with no checks produces neither errors nor warnings.
  8. Click Save.

The message Attribute saved appears. For individual channels that need a different rule, add an exception as described in How to manage rule exceptions.

The Validation Rules icon appears only for attribute types that support validation and does not appear for reference entity attributes.

Apply the rule to existing products

Saving rules does not revalidate products: the rule applies to a product when it is saved again. To apply it to all products immediately, you need access to the Maintenance administration area.

  1. In the menu, select Admin, then Maintenance.
  2. In the Validate all products row, click the Run icon.
  3. Confirm the action.

The message Event fired appears, and validation of all products continues in the background.