Skip to main content
Version: Next

Asset Relation Assignment

This action can be executed on an asset level and lets you automatically assign images to data objects based on specific meta information. The meta information can be contained in the filename or stored as custom metadata. Therefore, you can choose between two separate actions steps:

  • Object Relation Assignment By Name (asset_relation_object_name)
  • Object Relation Assignment By Metadata (asset_relation_object_meta)

Variant GeneratorVariant GeneratorVariant Generator

Available Context

For more information on context limitations refer to the Available Context section.

Multiselect: Yes Elements: Assets

Configuration Options

Object Relation Assignment By Name (asset_relation_object_name)

# Key of the field based on which the data object will be queried (e.g. id)
data_object_key:
isValueRegEx: false
value: 'id'

# Value of the field based on which the data object will be queried (e.g. 123)
data_object_key_value:
isValueRegEx: true
value: '/(?P<data>\d+)_/'

# Class of the data object (e.g. Car)
data_object_class:
isValueRegEx: false
value: 'Car'

# Field of the data object to which the asset will be assigned (e.g. imageField).
data_object_field:
isValueRegEx: true
value: '/(?P<data>[^_]+)\.\w+$/'
Detailed Configuration Options
  • data_object_key: Key of the field based on which the data object will be queried (e.g. id)
    • isValueRegEx: Define if value is regex that should be applied onto filename to extract value. If not, value is used directly.
    • value: Actual value, or regex. Regex has to define a named capture group <data>, that extracts the actual value.
  • data_object_key_value: Value of the field based on which the data object will be queried (e.g. 123)
    • isValueRegEx: Define if value is regex that should be applied onto filename to extract value. If not, value is used directly.
    • value: Actual value, or regex. Regex has to define a named capture group <data>, that extracts the actual value.
  • data_object_class: Class of the data object (e.g. Car)
    • isValueRegEx: Define if value is regex that should be applied onto filename to extract value. If not, value is used directly.
    • value: Actual value, or regex. Regex has to define a named capture group <data>, that extracts the actual value.
  • data_object_field: Field of the data object to which the asset will be assigned (e.g. imageField). Supported field types are image, gallery, many-to-many relation, many-to-one relation.
    • isValueRegEx: Define if value is regex that should be applied onto filename to extract value. If not, value is used directly.
    • value: Actual value, or regex. Regex has to define a named capture group <data>, that extracts the actual value.

Object Relation Assignment By Metadata (asset_relation_object_meta)

# Key of the field based on which the data object will be queried (e.g. id)
data_object_key:
# Define if value is stored in the asset metadata and provide the field key for it. If not, value is used directly.
isValueMeta: false
# Actual value, or metadata field key
value: 'id'

# Value of the field based on which the data object will be queried (e.g. 123)
data_object_key_value:
isValueMeta: false
value: 'id'

# Class of the data object (e.g. Car)
data_object_class:
isValueMeta: false
value: dataObjectClass

# Field of the data object to which the asset will be assigned
data_object_field:
isValueMeta: true
value: dataObjectField
Detailed Configuration Options
  • data_object_key: Key of the field based on which the data object will be queried (e.g. id)
    • isValueMeta: Define if value is stored in the asset metadata and provide the field key for it. If not, value is used directly.
    • value: Actual value, or metadata field key
  • data_object_key_value: Value of the field based on which the data object will be queried (e.g. 123)
    • isValueMeta: Define if value is stored in the asset metadata and provide the field key for it. If not, value is used directly.
    • value: Actual value, or metadata field key
  • data_object_class: Class of the data object (e.g. Car)
    • isValueMeta: Define if value is stored in the asset metadata and provide the field key for it. If not, value is used directly.
    • value: Actual value, or metadata field key
  • data_object_field: Field of the data object to which the asset will be assigned (e.g. imageField). Supported field types are image, gallery, many-to-many relation, many-to-one relation
    • isValueMeta: Define if value is stored in the asset metadata and provide the field key for it. If not, value is used directly.
    • value: Actual value, or metadata field key

Full Configuration Examples

pimcore_copilot:
automation_actions:
actions:
asset_relation_object_name:
triggers:
manual:
enabled: true
context_limitations: ['asset']
steps:
- step_implementation: 'asset_relation_object_name'
configuration:
data_object_key:
isValueRegEx: false
value: 'id'
data_object_key_value:
isValueRegEx: true
value: '/(?P<data>\d+)_/'
data_object_class:
value: 'Car'
data_object_field:
isValueRegEx: true
value: '/(?P<data>[^_]+)\.\w+$/'
post_execution_interaction: !php/enum Pimcore\Bundle\CopilotBundle\AutomationAction\Configuration\PostInteractionTypes::RELOAD_SUBJECT

As you can see in the example above, required parameters for assigning asset to the data object are extracted from the filename based on the regex pattern with the custom group name data or directly based on the value provided.

The regex provided in the example would extract parameters for the file with following name: asset_id-123_Car_image.jpg.

pimcore_copilot:
automation_actions:
actions:
asset_relation_object_meta:
triggers:
manual:
enabled: true
context_limitations: [ 'asset' ]
search_terms: [ ]
steps:
- step_implementation: 'asset_relation_object_meta'
configuration:
data_object_key:
isValueMeta: false
value: 'id'
data_object_key_value:
isValueMeta: false
value: 123
data_object_class:
isValueMeta: true
value: dataObjectClass
data_object_field:
isValueMeta: true
value: dataObjectField
post_execution_interaction: !php/enum Pimcore\Bundle\CopilotBundle\AutomationAction\Configuration\PostInteractionTypes::RELOAD_SUBJECT

In the example above, two of the required parameters for assigning asset to the data object are extracted from the asset metadata. The other two parameters are provided directly (id and 123).