Skip to main content

Config builder

This section provides an overview of the Config Builder and explains the structure of the XML configuration.

Predefined reports provided by the extension and Report builder can cover most cases for analyzing sales in a simple Magento store. However, the real stores and types of items they sell may require more advanced and flexible tools to analyze different parts of their sales. Also, real stores can have a lot of 3rd-party extensions with their own database tables that contain important data for sales/marketing/inventory analytics.

The Config builder is exactly the tool for such purposes. It is located in Reports -> Advanced Reports -> Config Builder.

The Config builder provides the ability to create Synthetic columns with complex data calculation/aggregation and to adjust relations between the native Magento database tables and tables from a 3rd-party or custom extension so the data in reports will be as accurate as possible.

Config builder overview

Open either the Report builder or Config builder menu, and select the Add New Config action on the right menu section. You will be brought to the Config workspace:

Config

Config builder

It is very simple and contains the following fields:

  • Title - the new synthetic field's name (named whatever you wish).
  • XML Config - column definition as XML document.

The structure of the XML config

config

This is the root element, e.g. all other tags should be contained inside it.
There are only 3 possible nodes allowed inside the config element - <table />, <eavTable />, <relation />.

table

This element must be used for registering tables so the extension will be able to retrieve data from them. This element also can be used for already defined tables to assign custom synthetic columns to them.
Allowed child elements: <pk />, <fk />, <column />.
Attributes:

AttributeDescriptionRequiredDefault
namename of the table. The name should be specified without the table prefix. This means that if you have in your database a prefix like mage_ and real table name mage_sales_order, you need to enter here just sales_orderrequirednone
groupname of a group, under which this table appears in the Report Builder. Default values: Sales, Products, Customers, Categories, Other.optionalOther
labelthe label of a table that is used in identifying a table.optionalthe value of the name attribute

eavTable

This element must be used for registering EAV tables so the extension will be able to retrieve data from corresponding EAV entities including their attributes. This element SHOULD NOT be used for native EAV tables like catalog_product_entity, catalog_category_entity, customer_entity, etc as these EAV entities are already registered in the extension.
Allowed child elements: <pk />, <fk />, <column />.
Attributes:

AttributeDescriptionRequiredDefault
namename of the table. The name should be specified without the table prefix. This means that if you have in your database a prefix like mage_ and real table name mage_sales_order, you need to enter here just sales_orderrequirednone
groupname of a group, under which this table appears in the Report Builder. Default values: Sales, Products, Customers, Categories, Other.optionalOther
labelthe label of a table that is used in identifying a table.optionalthe value of the name attribute
typethe type code of the EAV entity. The code can be found in the entity_type_code column in the eav_entity_type tablerequirednone

pk

The primary key of the table. This element is optional and SHOULD NOT be used on native tables.
Attributes:

AttributeDescriptionRequiredDefault
namethe name of the primary key columnrequirednone
labelthe labels for the columnoptionalthe value of the name attribute

fk

The foreign key is in the table. This element is optional and SHOULD NOT be used on native tables.
Attributes:

AttributeDescriptionRequiredDefault
namethe name of the foreign key columnrequirednone
labelthe labels for the columnoptionalthe value of the name attribute
tablethe relation table name without prefixrequirednone

column

This element is responsible for defining the column. This element is mostly used for synthetic columns with custom calculations.
Attributes:

AttributeDescriptionRequiredDefault
namethe name of the primary key columnrequirednone
labelthe labels for the columnoptionalthe value of the name attribute
typedata type of the column's value. The type defines how the value of the column will be displayed and possible aggregations for the column. The extension will automatically add columns with aggregations to the Column Chooser. Supported types: money, country, date, qty, number, select, percent, store, html. More information about data types you can check hereoptionalhtml
fieldscomma-separated list of fields, which will be used in calculationsoptionalif omitted the value from the name field will be used
exprthis attribute contains MySQL expression to calculate field value. You can use placeholders, where %1 corresponds to the first field in the previous attribute, %2 - to the second, and so on.optional%1
optionsnon-mandatory attribute where the data type select or country is used. Here you need to enter the full name or the class that implements the method toOptionArray for this column.optionalnone
tablescomma-separated list of table names (without prefix) for the ability to include columns from other tables inside the expr fieldoptionalnone
Column types:
TypeDescriptionAggregators
htmlSimple string, Output values as it isJOIN
numberNumber rounded to 2 decimal pointsSUM, AVG
qtyInteger value, mostly used for ID fieldsCOUNT
percentValue formatted as a percentage with % symbol, rounded to 2 decimal pointsAVG
moneyCurrency format, displays numbers with currency symbol, rounded to 2 decimal points. If the report is filtered by one particular store the value will be displayed in the default currency for that store. Otherwise, the default store currency will be usedSUM, AVG
dateDate format, Depending on the aggregation type the output may varyHOUR, DAY, DAY OF WEEK, MONTH, QUARTER, YEAR
selectThe type for the field with predefined variations for values. With this type, the options attribute SHOULD be used in the column elementJOIN
countrySimilar to the select type. If the value of the column is in the ISO 3166-1 alpha-2 format then class Mirasvit\Report\Config\Source\Directory\Country can be used as the value of the options attribute in the column elementJOIN
storeSimilar to the select type but store labels will be retrieved by the extension so the options attribute SHOULD NOT be used along with this data typenone

relation

The module should determine how to link different tables to build reports from multiple tables.
The connection between two or more tables is called a table relationship.
The < relation /> element is responsible for defining relations between tables.
Required child elements: <leftTable />, <rightTable />, <condition />.
Attributes:

AttributeDescriptionRequiredDefault
namethe name of the relation. the name can be any string but it is recommended to use the following format: leftTable-rightTablerequirednone
typethe type of the relation between tables. Possible values:
11 - one to one;
1n - one to many.
requirednone

leftTable, rightTable

This element is responsible for defining tables in the relation in the next format: <leftTable>sales_order_item</leftTable>. The table name should be specified without the table prefix. These elements don't have attributes.

condition

This element is responsible for defining JOIN conditions between leftTable and rightTable using MySQL syntax. You can use placeholders %1 and %2 where %1 is a placeholder for the letTable and %2 - for the rightTable