Examples of configs
On this page you will find examples of configs created with the Config Builder. Use them as a starting point for your own columns and table relationships. Before saving, click Check against schema to see what a config changes.
Calculated money column
A column on orders that calculates the gross profit based on invoiced amounts. expr converts the value to the base currency with the order's rate, and store_expr is used when the report is filtered by a single store.
{
"datasets": [
{
"name": "sales_order",
"columns": [
{
"name": "custom_gross_profit",
"label": "Custom Gross Profit",
"kind": "measure",
"type": "number",
"value_format": "money",
"aggregation": "sum",
"expr": "(sales_order.base_subtotal_invoiced - IFNULL(sales_order.base_total_invoiced_cost, 0) - IFNULL(sales_order.base_total_refunded, 0)) * IF(sales_order.base_to_global_rate > 0, sales_order.base_to_global_rate, 1)",
"store_expr": "sales_order.base_subtotal_invoiced - IFNULL(sales_order.base_total_invoiced_cost, 0) - IFNULL(sales_order.base_total_refunded, 0)"
}
]
}
],
"explores": []
}
Column with data from another table
A column on cart items that reads the currency rate from the cart (quote). A reference to another dataset of the explore joins that dataset, so no relationship needs to be declared.
{
"datasets": [
{
"name": "quote_item",
"columns": [
{
"name": "custom_row_total",
"label": "Row Total (Base Currency)",
"kind": "measure",
"type": "number",
"value_format": "money",
"aggregation": "sum",
"expr": "quote_item.base_row_total * IF(quote.base_to_global_rate > 0, quote.base_to_global_rate, 1)",
"store_expr": "quote_item.base_row_total"
}
]
}
],
"explores": []
}
Shipment date per order item
This config shows the shipment date for each order item, even if items of one order were shipped separately.
First, the sales_shipment_item and sales_shipment tables are registered as datasets. Then two relationships in the sales explore connect order items to shipment items, and shipment items to shipments. After that, the Shipment Date, Shipment # and Shipped Qty columns become available in reports built on the sales explore.
{
"datasets": [
{
"name": "sales_shipment_item",
"label": "Shipment Items",
"group": "Sales",
"connection": "sales",
"sql_table_name": "sales_shipment_item",
"columns": [
{
"name": "entity_id",
"kind": "dimension",
"type": "number",
"primary_key": true,
"hidden": true
},
{
"name": "qty",
"label": "Shipped Qty",
"kind": "measure",
"type": "number",
"aggregation": "sum"
}
]
},
{
"name": "sales_shipment",
"label": "Shipments",
"group": "Sales",
"connection": "sales",
"sql_table_name": "sales_shipment",
"columns": [
{
"name": "entity_id",
"kind": "dimension",
"type": "number",
"primary_key": true,
"hidden": true
},
{
"name": "increment_id",
"label": "Shipment #",
"kind": "dimension",
"type": "string"
},
{
"name": "created_at",
"label": "Shipment Date",
"kind": "dimension",
"type": "datetime",
"timeframes": ["date", "week", "month", "year"]
}
]
}
],
"explores": [
{
"name": "sales",
"relationships": [
{
"name": "sales_shipment_item-sales_order_item",
"join": ["sales_shipment_item", "sales_order_item"],
"condition": "sales_shipment_item.order_item_id = sales_order_item.item_id",
"type": "1n"
},
{
"name": "sales_shipment_item-sales_shipment",
"join": ["sales_shipment_item", "sales_shipment"],
"condition": "sales_shipment_item.parent_id = sales_shipment.entity_id",
"type": "1n"
}
]
}
]
}
EAV attribute override
A product, category, customer or customer address dataset discovers all its attributes by itself, so its config lists only the attributes you want to change. This config changes the label of the customer's group and shows group names instead of IDs.
{
"datasets": [
{
"name": "customer_entity",
"eav_entity_type": "customer",
"columns": [
{
"name": "group_id",
"label": "Customer Group",
"kind": "dimension",
"type": "string",
"value_format": "select",
"source_model": "Mirasvit\\AdvancedReports\\Schema\\Type\\Options\\Customer\\Group"
}
]
}
],
"explores": []
}
Active special price column
This config creates a product column that displays the special price when it is active on the current date. It can help build a report that lists products with active special prices.
{
"datasets": [
{
"name": "catalog_product_entity",
"columns": [
{
"name": "active_special_price",
"label": "Active Special Price",
"kind": "dimension",
"type": "number",
"value_format": "money",
"expr": "IF(DATE(IFNULL(catalog_product_entity.special_from_date, '1970-01-01')) <= CURDATE() AND DATE(IFNULL(catalog_product_entity.special_to_date, CURDATE())) >= CURDATE(), catalog_product_entity.special_price, NULL)"
}
]
}
],
"explores": []
}
The Test tab of the config editor cannot run expressions on product attributes. Save the config and check the column in a report.
For a config that brings in data from a 3rd-party extension, see How to use data from other modules in reports.