Skip to main content
Version: 2024.4

Variant Generator

This action step can be executed on an object context and lets you create variants of a data object by providing additional inputs for the new variants.

Variant GeneratorVariant GeneratorVariant Generator

Available Context

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

Multiselect: Yes Elements: Data Objects

Configuration Options

# defines data object class objects should be created for
class_name: 'Pimcore\Model\DataObject\Car'

# defines environment variable name that defines the matrix for variants to be created
matrix_variable: Variants

# defines field mappings from environment variables matrix to actual field names of the data object
field_mappings:

# simple mapping: key is data object field name, value is matrix column name
key: Color
productionYear: ProductionYear

# optional advanced mapping:
# - key is data object field name
# - matrixColumn is matrix column name
# - optional transformers can transform the matrix value
color:
matrixColumn: Color
transformers: ['asArray']

Transformers

Transformers can be used to transform values from the matrix into different data types before assigning them to data object attributes. E.g. it might be necessary to transform a single value into an array in order to assign it to a multiselect field.

Available transformer implementations

  • asArray: Transform value to an array.

For details on creating custom transformers see Transformers.

Full Configuration Example

pimcore_copilot:
automation_actions:
actions:
car_variant_generator:
triggers:
manual:
enabled: true
context_limitations: ['object_car']
search_terms: []
environment_variables:
- name: Published
type: Pimcore\Bundle\CopilotBundle\AutomationAction\Configuration\Environment\Type\Checkbox
- name: ObjectType
type: Pimcore\Bundle\CopilotBundle\AutomationAction\Configuration\Environment\Type\Select
configuration:
required: true
values:
- key: object
value: Object
- key: variant
value: Variant
- name: Variants
type: Pimcore\Bundle\CopilotBundle\AutomationAction\Configuration\Environment\Type\Matrix
configuration:
required: true
columns:
- name: Color
type: Pimcore\Bundle\CopilotBundle\AutomationAction\Configuration\Environment\Type\Select
configuration:
required: true
values:
- {'key': 'grey', 'value': 'Grey'}
- {'key': 'beige', 'value': 'Beige'}
- {'key': 'silver', 'value': 'Silver'}
- {'key': 'brown', 'value': 'Brown'}
- {'key': 'orange', 'value': 'Orange'}
- {'key': 'yellow', 'value': 'Yellow'}
- {'key': 'blue', 'value': 'Blue'}
- {'key': 'black', 'value': 'Black'}
- {'key': 'green', 'value': 'Green'}
- {'key': 'red', 'value': 'Red'}
- {'key': 'white', 'value': 'White'}
- name: ProductionYear
type: Pimcore\Bundle\CopilotBundle\AutomationAction\Configuration\Environment\Type\Number
configuration:
required: false
steps:
- step_implementation: 'variant_generator'
configuration:
class_name: 'Pimcore\Model\DataObject\Car'
matrix_variable: Variants
field_mappings:
key: Color
color:
matrixColumn: Color
transformers: ['asArray']
productionYear: ProductionYear

post_execution_interaction: !php/enum Pimcore\Bundle\CopilotBundle\AutomationAction\Configuration\PostInteractionTypes::RELOAD_SUBJECT

Additional Environment Variables

  • Published: Checkbox to define if the created variants should be published immediately. Default is false.
  • ObjectType: Select Type what type of object should be created. Either object or variant. Default is object.

For an example how to configure the additional environment variables see the full configuration example above.