The Advanced Data Types module extends AtroCore's data management capabilities by enabling full configuration of Relation entities, providing Script type for fields and attributes, and implementing dynamic relationship management. This module enables complex data structures and automated data processing through script-based calculations and dynamic selections.
Relation Entity Management
Relation entities are automatically created when establishing Many-to-Many relationships between entities. The Advanced Data Types module enables full management of these Relation entities, allowing you to customize their structure and behavior beyond the basic relationship functionality.
For general guidance on working with entities, refer to Entity management.
Relation entities are automatically generated with:
- Two link fields connecting the related entities
- Standard system fields (ID, Created At, Created By, etc.)
- Entity name formed by combining the related entity names
Relation entities are also created for hierarchical entities to manage parent-child relationships (e.g., ProductHierarchy for Product entity).
With the Advanced Data Types module, Relation entities can be fully customized:
- Field Management: Add custom fields to store additional relationship data - see Fields and Attributes
- Navigation Integration: Display Relation entities in Navigation and Favorites menus
- UI Configuration: Modify labels, set Text Filter Fields, and configure Default Order - see Entity management for details
- Additional Relationships: Create links with other entities - see Fields and Relations
Attributes cannot be used with Relation entities.
As an example, the "Product Channels" entity links Products and Channels, and includes an "Active" checkbox field to control product availability per channel — demonstrating how Relation entities can store relationship-specific data.
Script Attributes and Fields
New data type Script
for attributes and fields is included in this module to enable dynamic value calculation using Twig Templating. This functionality allows you to create computed values based on existing data, perform conditional logic, and reference related entity information.
Refer to Fields and Attributes and Attributes on how to work with fields and attributes in general.
Script Configuration
Script attributes and fields are configured with:
- Output Type Selection: Choose the data type for the script result, such as Text, Integer, Float, Boolean, Date, or Date-time. For attributes additional type HTML is available.
- Script Definition: Write Twig code to define the calculation logic
- Preview: Use the "Script value" field to preview the calculated result
The preview uses a random entity record (e.g., "test"). The preview updates only after saving the script field.
Script Limitations
Script fields are primarily designed for export purposes to collect additional data and present it in formats expected by external systems. Script values are calculated when reading the record (during export or detail view access), not stored in the database.
Due to their calculated nature, script fields cannot be used in search and filtering operations. Additionally, script field values cannot be manually set or modified — they are automatically calculated based on the defined Twig code.
Script Examples
Product-Specific Value Selection
This example demonstrates finding a specific product and extracting related information:
{# Find the product entity by name #}
{% set product = findEntity('Product', {'name': 'test'}) %}
{# Display product name and creation date #}
{{ product.name }}, createdAt {{ product.createdAt }}
{# Get all assets related to the product #}
{% set productAssets = findRecords('ProductFile', {'productId': product.id}) %}
{# Loop through assets and display the main image #}
{% for productAsset in productAssets %}
{% if productAsset.isMainImage == true %}
Main image - {{ productAsset.file }}
{% endif %}
{% endfor %}
Keep in mind that this script always searches for the product named 'test', so it displays data for that product regardless of which record you run it from.
Attribute Value Referencing
You can simply reference the attribute of current entity using its code (or ID if the code is not set), for example: {{ entity.attribute_code }}.
And if you need to reference the attribute of a different entity - use function putAttributesToEntity
first and then reference them as usual.
Conditional Logic
Scripts support conditional statements for dynamic value calculation:
This example checks if a product Long Description
is empty and returns a boolean result accordingly.
Link Type for Attributes
The Advanced Data Types module extends the Link
data type to be available for attributes, not just fields. This enables creating relationships between entities through attributes, providing more flexible data modeling capabilities.
Link attributes support the same configuration options as Link fields:
- Dropdown: Displays the attribute as a dropdown selection in the UI
Link attributes create optional relationships between different entities, allowing you to establish connections through attribute values rather than dedicated field relationships that exist for all records.
Dynamic Relations
Dynamic Relations provide efficient entity linking through filter-based selections without creating physical database relationships. This approach is particularly valuable for large datasets where traditional many-to-many relationships would be impractical or when selection criteria change frequently.
Dynamic Relations work by:
- Creating virtual relationships based on search criteria
- Displaying filtered records in related entity panels
- Enabling real-time updates when criteria change
- Supporting one-way relationships (from target to source entity)
Performance: Dynamic Relations are ideal for large datasets (e.g., 3 million products) where direct linking would be time-consuming and maintenance-intensive.
Creating Dynamic Relations
Dynamic Relations are managed through Administration \ Dynamic Relations
.
Configure the Dynamic Relation settings:
- Active: Enable the Dynamic Relation
- Name: Unique identifier for the relation
- Target Entity: Entity where the filtered panel will appear
- Source Entity: Entity to filter records from
- Link Label: Panel title on the target entity page
- Backward Link Label: Panel title on the source entity page
Creating Dynamic Selections
Dynamic Selections define the filtering criteria for Dynamic Relations. Add them through the relation panel in Dynamic Relations or directly from the entity page Dynamic Selection
.
Relation panels and filter button become available only after the Dynamic Selection record is saved.
Fields:
- Name: Descriptive name for the selection
- Active: Enable the Dynamic Selection
- Dynamic Relation: Choose the previously created Dynamic Relation
Source records
panel shows records of the Source entity. To set or change the filter, press the filter button in the header. Set the necessary filter in the right panel as described in Search and filtering and apply it by pressing the Apply Search
button. Results appear in the Source records
panel.
The bottom panel shows records of the Target entity for which this particular selection will apply (Category in this case). Manually add or remove desired records for this panel using the panels menu. See Record management for details.
Using Dynamic Relations
Once configured, Dynamic Relations can be added in layouts for entity detail page (both Target and Source entities):
The panel displays records matching the defined criteria, updating automatically when the source data changes.
Enabling Bidirectional Navigation
Dynamic Relations work primarily in one direction (from target to source entity). For example, when viewing a Category, the system displays all Products that match the selection criteria. However, viewing the reverse relationship (from Product to Category) requires additional processing.
To enable bidirectional navigation, use the Refresh Cache for Dynamic Relations scheduled job, which caches all dynamic selection results and allows backward navigation from source to target entities.
Caching: The system includes caching mechanisms and job scheduling options to optimize performance for large datasets. Caching is also required for bidirectional navigation to function properly.