You can clone with
HTTPS or Subversion.
Using Piwik 1.11.1, I try to use Piwik API method Goals.getItemsName to fetch top products by:
Unfortunately, it looks like sorting by quantity does not work there. In fact any sorting using filter_sort_column and filter_sort_order does not work. Only if I don't pass these parameters, results are sorted by revenue in descending order. When trying to sort the list any other way, the order does not make any sense to me and for sure it's not what I wanted.
I wasted some time to browse the code, but it didn't help me anyway. I see, that Goals API sorts results by revenue in descending order by default, no matter if I pass sort/order options or not. If these parameters are passed, it converts them to magic numbers specified in Piwik_Archive and sorts data.
The first problem I see is that core/DataTable/Filter/Sort.php in method selectColumnToSort() uses Piwik_Archive::$mappingFromNameToId array. In that array there's column revenue, but e.g. quantity column is not present, so sorting by that column seems to be impossible - it takes nb_visits by default in such case.
I tested the behaviour on two Piwik instances: one which is tracking real ecommerce site and one fresh installation with fake generated data.
On the fake instance I noticed that each row of results can have different set of columns, i.e. revenue and nb_visits disappear randomly. But maybe that's something broken in visits generator.
On the live instance I don't see such issues with disappearing columns, but results remain unsorted anyway.
Can you tell, if that's bug or feature? I am not sure though. I looked through the code hoping it will make things cleaner to me, but now I see how complex and unclear it is. I haven't got whole day to spend on debugging it, even not being sure if my fix would be real fix, not a hack.
It's a bug. thanks for the report. Maybe will take a few months to fix as it's non trivial (sorting works for most other columns except processed ones).
this was fixed in 2.0