Functions and filters
This page documents custom Simplia functions. For standard Twig functions and filters, see the official Twig documentation. For an overview of custom Simplia filters, see the Simplia filters section.
uniqueEntities
Processes an array of entities, removes duplicates, and optionally limits the result to a given count. A typical use case is displaying five products that are similar, in the same category, or on sale (depending on what is available).
If a maximum count is defined, items are iterated only until the count is met. If two product listings are defined as sources and the count is already satisfied by the first, the second is never loaded from the database.
twig
{% for image in uniqueEntities([product.image, product.currentImages, product.imagesWithoutEnumValue], 5) %}
{{ image.alt }}
{% endfor %}