This feature needs the MauticCustomObjectsBundle plugin. Make sure it’s installed and active in Mautic.
Getting Custom Object Data
Use thegetCustomObjectItems
function to fetch data from a specific Custom Object.
getCustomObjectItems(alias, limit, page, orderBy, orderDirection, search, contactId)
What the options mean:
alias
(Required): The unique name (alias) of your Custom Object (e.g.,'orders'
).limit
: How many items to get (default is 1000).page
: Which page of results to get (for pagination, default is 1).orderBy
: How to sort the items ('id'
or'name'
, default is'id'
).orderDirection
: Sort direction ('ASC'
for A-Z,'DESC'
for Z-A, default is'ASC'
).search
: Text to search for within the items (optional).contactId
: Get items linked only to a specific contact ID. Usecontact.id
for the current contact (optional).
id
: The item’s ID.name
: The item’s name.fields
: A collection of all the custom field values for that item. You access them using their alias (e.g.,item.fields.your_field_alias
).
Using the Data
After fetching the items (e.g.,{% set myItems = getCustomObjectItems('orders') %}
), you can loop through them and show their details: