mage-os / module-advanced-report
Advanced sales and catalog reporting for Magento Open Source / Mage-OS.
Package info
github.com/mage-os-lab/module-advanced-report
Type:magento2-module
pkg:composer/mage-os/module-advanced-report
Requires
- php: ~8.3.0||~8.4.0||~8.5.0
- magento/framework: *
- magento/module-backend: *
- magento/module-catalog: *
- magento/module-catalog-inventory: *
- magento/module-config: *
- magento/module-customer: *
- magento/module-directory: *
- magento/module-eav: *
- magento/module-payment: *
- magento/module-quote: *
- magento/module-reports: *
- magento/module-sales: *
- magento/module-shipping: *
- magento/module-store: *
- magento/module-ui: *
- magento/module-user: *
Requires (Dev)
- bitexpert/phpstan-magento: ^0.44
- friendsofphp/php-cs-fixer: ^3.95
- magento/magento-coding-standard: ^41
- phpmd/phpmd: ^3@dev
- phpstan/phpstan: ^2.2
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^13.3
- rector/rector: ^2.6
Suggests
- magento/module-checkout: Provides the checkout/cart/delete_quote_after setting read by the cart reports; the default is used when it is not installed.
- magento/module-inventory-api: Used to read multi-source stock levels for the catalog_stock dataset and, with the modules below, to enable the catalog_salable dataset.
- magento/module-inventory-catalog: Required by the catalog_salable dataset.
- magento/module-inventory-indexer: Required by the catalog_salable dataset.
- magento/module-inventory-reservations: Required by the catalog_salable dataset.
Provides
None
Conflicts
None
Replaces
None
README
Advanced sales, catalog and customer reporting for Magento Open Source / Mage-OS. It adds an admin exploration app (Reports > Advanced Report) on top of a declarative semantic layer: datasets, fields, metrics and dimensions are declared in XML and translated to SQL by a MySQL data source.
Features
- Predefined reports (sales overview, sales by payment/shipping method/country/customer group/hour/weekday,
new vs returning customers, coupon performance, product performance, sales by category/attribute,
customer value, new customer registrations, stock value, low stock with coverage, dead stock, never sold,
recent carts and cart items, abandoned carts (trend, list, top products), products added to cart, cart conversion,
and, only while
MageOS_RMAis enabled, returns: overview, withdrawals before shipment vs returns after shipment, returns by reason/status/resolution/item condition, open requests, top returned products, product and order return rates, return rate by shipping country). - Free exploration: pick metrics, group by dimensions, filter, compare to the previous period/year, chart and table, CSV export.
- A
marketingarea (ACLMageOS_AdvancedReport::marketing) that stays empty until a source module such asMageOS_GoogleAdvancedReport(Google Analytics 4 import) contributes datasets and presets to it. - Saved reports (private or shared with other admins) stored in
mageos_advancedreport_saved. - Everything is computed live from the native Magento tables (no aggregation tables, no cron).
See architecture for how reports are built from the semantic layer.
Requirements
- Magento Open Source 2.4.7+ or Mage-OS, PHP 8.3+ (CI matrix and status: compatibility).
- Database: MySQL 8.4 or MariaDB 11.4 (tested in the CI integration matrix); MySQL 8.0 and MariaDB 10.6 are
declared, not tested. The report guardrail uses
MAX_EXECUTION_TIMEon MySQL andmax_statement_timeon MariaDB. - The
advanced_reportcache type must be enabled for result caching (reports still work with it disabled, uncached). - A
db/table_prefixinapp/etc/env.phpis supported: every table the module reads is resolved through the report connection (CI runs the integration suite once with prefixpre_). Custom code that adds SQL must do the same, see extending. Magento_Reports(hard dependency: the admin menu entry is a child of the Reports menu).- Recommended: MySQL/MariaDB timezone tables (
mysql_tzinfo_to_sql) when stores use a non-UTC timezone, see time and currency. - Optional: Magento MSI (
Magento_InventoryApi) for multi-source stock in thecatalog_stockdataset; the legacycataloginventory_stock_itemtable is used otherwise.
Installation
composer require mage-os/module-advanced-report bin/magento module:enable MageOS_AdvancedReport bin/magento setup:upgrade bin/magento cache:flush
setup:upgrade creates the mageos_advancedreport_saved table and adds the indexes the reports need on sales_order,
sales_order_item and quote. The index build is online but costs I/O and replica lag on large tables: read
indexes before installing on a large store.
Then configure the module in Stores > Configuration > Advanced Report (see configuration) and open Reports > Advanced Report. Before upgrading an existing installation read upgrading.
Documentation
- Architecture: building blocks of the semantic layer, request flow, charts, roadmap.
- Configuration: every setting with its default.
- Upgrading: steps after every upgrade, changes in this release, disabling the module.
- Metric definitions: business definition of every metric (formula, cancel/refund treatment, currency, date attribution, additivity, known limits) with the integration tests that prove it, customer dimensions, return presets, and physical vs reserved vs salable quantities.
- Metric inventory: generated list of every metric, its joins, fan-out risk and dependencies.
- Time and currency: timezone used for filtering, grouping, comparison and display, DST, the fallback without timezone tables, the currency of every financial metric, rejection rules and rounding.
- Extending: adding datasets, fields, metrics, dimensions and presets from another module; PHP extension points.
- Console commands:
advanced-report:explain,advanced-report:benchmark,advanced-report:inventory. - Performance: statements per report, safeguards, benchmark procedure and results table, bottlenecks, async evaluation.
- Cache: cache key, TTLs, invalidation, label staleness, failures, stampede lock and freshness per report category.
- Indexes: rationale of every index, removable indexes, installation time and maintenance window.
- Security: ACL model per entry point and dataset, data classification, field level ACL, cache and logging.
- Risk register: known limits and risks with severity and owner.
- Compatibility: supported Magento, PHP and database versions and the CI job enforcing each.
- Testing: local quality and integration commands, CI jobs and the database matrix.
Contributing
Issues and pull requests are welcome on GitHub. Please follow the Magento coding standard, keep the semantic layer rules described in extending (no SQL in metrics, bound parameters only) and include unit tests for new classes.
License
This module is licensed under the MIT License.
Support
For bugs or feature requests, please open an issue in the GitHub repository.