Setting Up Automatic Links on Assets Import

📘

Learning Objectives

  • Understand automatic links to associate assets with product sheets or variants.
  • Set up a rule based on naming conventions and regular expressions.
  • Simplify assets management by automating their linking to products.


Introduction

With automatic links, you can save time and ensure consistency in assets management by defining rules suited to your business needs. This optimizes both the time required and the accuracy when enriching product sheets with assets in the PIM.

This course will guide you step-by-step to set up automatic links between assets and documents or variants. You will learn to define rules to automatically associate assets based on their file names.

👍

Good to know

Programming skills are required to create automatic link rules, as the process involves:

  • creating a regular expression (regex),
  • JSON declarations.

For support in implementing this feature, reach out to your integration partner.



Understanding the Principle of Automatic Links

Quable PIM's rule engine allows you to establish a match between an asset item and a document or variant, based on a naming convention and regular expressions (regex).

  1. An asset item is uploaded to Quable PIM from the DAM, imports, or via API,
  2. The rule engine analyzes the file name to extract specific information (such as a product code),
  3. An automatic link rule checks if a matching object (product sheet or variant, as appropriate) exists,
  4. If a match is found, the asset item is automatically linked to the target.

👍

Good to know

Automatic links are only applied when a asset sheet is created, during the upload of assets in the DAM. They are not triggered when an existing asset sheet is updated or modified.



Definingn a asset Naming Convention

Linking rules work by interpreting the asset name using a regular expression. It is essential to adopt a consistent naming convention so that assets can be correctly associated with documents or variants.

👍

Best practices

  • Include a unique identifier of the document in the file name (e.g., product code).
  • Use a simple and structured naming format.
  • Separate key elements with specific characters (e.g., _, (), -).

Examples of valid file names:

tshirt_1234.jpg
product-5678.png
(item)jeans-42.svg

In these examples, 1234, 5678, and jeans-42 are the identifiers of the documents to link.



Creating an Automatic Link Rule

Access Rule Management

  • From the administration menu, under the System section go to Automatic Links.
Capture d’écran 2025-02-12 à 10.58.04.png
  • Click Create Automatic Link to create a new automatic link rule.
Capture d’écran 2025-02-12 à 10.58.53.png

Fill in Rule Parameters

Capture d’écran 2025-02-12 à 10.58.48.png

You must define several key elements:

1. Configuration Name (Slug)

  • A readable identifier for the rule (e.g., product_images_link).

2. Event

  • Indicates the event that triggers the rule.
  • Value to always use: mediaupload (corresponds to the creation of a new asset sheet).

3. Define Conditions: Rule if

The conditions that must be met for the rule to be applied. These should be written in the format below, exactly as shown. These conditions identify:

  • The type of document to which the rule applies,
  • How to identify the correct document type,
  • How to interpret the asset name,
  • The part of the asset name to use.
Request Body CodeDescription
"target_document_type"Unique code of the document to be linked. If:

- the value is code_du_doctype, this indicates that the rule targets a document
- the value is quable_sku, this indicates that the rule targets a variant
"target_value_type": ”code”
ou
"target_value_type": ”eav”
- "code" - indicates that the rule uses a document or variant code.
- "eav" - indicates that the rule uses an attribute value.
"target_value": ””If:
-"target_value_type": ”code”, this should be an empty string ("").
-"target_value_type": ”eav”, this should be the attribute code (e.g., "target_value": "color").
"rule": ”equal”Indicates that the isolated part of the asset name must exactly match the document type or attribute code. This must be entered exactly as shown.
"from_value_regex"A regular expression (regex) used to isolate segments of the assets names (in parentheses, also called capture groups). Characters that need to be escaped should be escaped twice with a backslash (e.g., \. for a period instead of .). By default, the first capture group is examined unless from_value_regex_group is used to specify a group. If you're new to regular expressions, you can refer to this site and this site.
"from_value_regex_group"(optional) An integer (number) indicating the capture group to use for document search (1 = first group, 2 = second group, etc.).
"from_value_type": "originalfilename”Must be entered exactly as shown.
"from_value": ””Must be entered exactly as shown.

Example of JSON Rule if

{
  "target_document_type": "product",
  "target_value_type": "code",
  "target_value": "",
  "rule": "equal",
  "from_value_regex": "/^(\\w+)_([0-9]+)\\.\\w+$/",
  "from_value_regex_group": 2,
  "from_value_type": "originalfilename",
  "from_value": ""
}

🔍 Breaking Down the Parameters

  • "target_document_type": "product" → Assets will be linked to documents of type "product".
  • "target_value_type": "code" → Linking is done using the document code.
  • "from_value_regex": "/^(\\w+)_([0-9]+)\\.\\w+$/" → Regular expression used to extract the document code.
    • Example Match: tshirt_1234.jpg
    • \w+ → Alphanumeric text (e.g., tshirt).
    • _ → Separator.
    • ([0-9]+) → Numeric product code (1234).
  • "from_value_regex_group": 2 → The second capture group (1234) is used to identify the document.

👍

Good to know

  • When "target_value_type": "eav" is used for a rule based on an attribute value, the default language of the PIM is considered for localized attributes.
  • "rule": ”equal”, "from_value_type": "originalfilename" and "from_value": "" must always be written as indicated.

4. Defining the Action: Rule then

This section describes the actions to take when the rule conditions are met. They must be written in the format below, exactly as shown:

Request Body CodeDescription
"action": ”createXObject”Must be used exactly as written. It tells Quable to create a link between the asset and the document.
"document_type": ""The value is the unique code of the link doc_type > asset to use. The default link type is article_images_media. In the case of a variant, the unique code value is sku_images_media.
See Link Types  for more on creating link types.
"sequence_regex" (optional) A regular expression (regex) defining the order of assets items.
Note: the sequence number must be included in the originalfilename of the asset.
"target_property": "originalfilename" (optional) Specifies that sequence_regex is in the asset name.
"side_entity": ”target”Must be used exactly as written. It makes the asset a child entity of the linked document.

Example of JSON Rule then

{
  "action": "createXObject",
  "document_type": "product_images_media",
  "side_entity": "target"
}

🔍 Breaking Down the Parameters

  • "action": "createXObject" → Tells Quable PIM to create a link between the asset and the document.
  • "document_type": "product_images_media" → Link type (here, linking between a product and its images).
  • "side_entity": "target" → Defines the asset as a child of the document.

👍🏼

Good to know

"action": "createXObject" and "side_entity": ”target” must always be written as indicated.




Test and Validate the Rule

Once the rule is created:

  • Upload an asset file into Quable PIM, following the defined naming convention.
  • Check if the link is created correctly by reviewing the corresponding document's details.

🚧

Warning

  • Each rule is specific to a document type. If multiple document types need to be automatically linked, you must create multiple rules, one for each document type.
  • The uploaded files must strictly adhere to the defined naming convention.


Edit or Delete a Rule

Edit a Rule

  • Access the list of existing rules.
  • Select a rule and click Edit.
Capture d’écran 2025-01-22 à 11.31.59 modif.png
  • Modify the parameters and then click Save.

Delete a Rule

  • Access the list of existing rules.
  • Select the rule to delete.
  • Click Delete and confirm the action.
Capture d’écran 2025-01-22 à 11.31.59 supp.png

Attention

This action is irreversible. A deleted rule cannot be recovered.



Best Practices

  • Define a clear naming convention and communicate it to the teams.
  • Test the rules with different files before large-scale deployment.
  • Use precise regular expressions to avoid incorrect associations.
  • Create separate rules for each document type.
  • Ensure that the asset files strictly follow the syntax defined in the rule.


📘

In Summary

  • How automatic linking works: A rule engine analyzes the asset file name and automatically links it to a document or variant if it matches the defined criteria.
  • Configuration: The link relies on a regular expression that extracts a key piece of information (e.g., product code) from the file name.
  • Creating a rule: Via the administration interface, defining conditions (Rule if) and actions (Rule then) in JSON format.
  • Best practices:
    • Adopt a clear naming convention, test rules before deployment, and ensure correct assets file syntax.
    • After creation, test asset uploads to ensure that associations work correctly.


Next Chapter

Congratulations! You've completed the "Setting Up Automatic Links on Assets Import" course. Continue your learning by exploring the next module in the Administrator Training.