[Bug] Goals.getItemsName (format=html) ignores filter_sort_column, always sorts by nb_visits
What happened?
When requesting the Ecommerce Products report through the controller action used by the UI (module=Goals&action=getItemsName&format=html) with filter_sort_column=revenue&filter_sort_order=desc, the returned/rendered rows are not sorted by revenue. Instead they come back sorted by nb_visits, regardless of the requested sort column.
The affected site tracks both orders and setEcommerceView product-page views, so some rows have revenue/quantity/orders while others (view-only) only have nb_visits/nb_actions.
Example request (idSite=829, period=month, date=2026-08-19, filter_limit raised to 2438 to rule out any limit/sort interaction):
index.php?module=Goals&action=getItemsName&format=html&idSite=829&period=month&date=2026-08-19&viewDataTable=table&abandonedCarts=0&totals=1&keep_totals_row=1&filter_offset=0&filter_limit=2438&filter_sort_column=revenue&filter_sort_order=desc
Resulting nb_visits values in row order: 19, 15, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, ... — a clean descending nb_visits order. The revenue values in the same rows jump around arbitrarily (0 €, 0 €, 200.80 €, 0 €, 0 €, 794.38 €, 0 €, 0 €, 195 €, 80.74 €, ...), i.e. not sorted at all.
By contrast, the plain Reporting API call for the same report/site/period sorts correctly:
inde
What should happen?
Both request paths should honor filter_sort_column/filter_sort_order identically, since they query the same underlying report. Clicking "Product revenue" in the UI should sort the Products table by revenue descending, the same way the plain API call does.
How can this be reproduced?
- On an ecommerce site that tracks both orders and setEcommerceView product-page views, open Ecommerce > Products for a period with a healthy mix of purchased and merely-viewed products.
- Click the "Product revenue" column header to sort descending, or manually call: index.php?module=Goals&action=getItemsName&format=html&idSite=&period=month&date=&viewDataTable=table&abandonedCarts=0&totals=1&keep_totals_row=1&filter_offset=0&filter_limit=<row_count>&filter_sort_column=revenue&filter_sort_order=desc
- Compare the row order to the nb_visits values in the same rows — they will be in descending nb_visits order instead of descending revenue order.
- For comparison, call the same report via the plain API and see that it sorts correctly: index.php?module=API&method=Goals.getItemsName&format=JSON&idSite=&period=month&date=&expanded=1&abandonedCarts=0&filter_sort_column=revenue&filter_sort_order=desc&filter_limit=20&token_auth=
Matomo version
Matomo version: 5.11.0 (on-premise)
PHP version
8.4.2
Server operating system
Ubuntu
What browsers are you seeing the problem on?
Firefox
Computer operating system
Linux Mint
Relevant log output
Validations
- Read our Contributing Guidelines.
- Follow our Security Policy.
- Check that there isn't already an issue that reports the same bug to avoid creating duplicates.
- The provided steps to reproduce is a minimal reproducible of the Bug.
Source: matomo-org/matomo