Best selling report counts sales incorrectly

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
I was doing an update from 3.x to 4.4 and as I was smoke testing the upgrade in a test environment i noticed that the reports for best selling products was wrong. A quick glance showed that for some of my products their sales were being doubled. I doubled checked the data in the database and it all seems to be correct.  I started to debug the code, at some point in the past someone added in the Category to the query for the best seller report and because of that left join it will count your sales 1 time for each category that product is in.  in my case i had a few of my best sellers in two categories and there for my sales were doubled for them.

I would assume that sales for an order item should be counted only once, no matter how many categories that product is in.

to reproduce just add a couple categories to a product, makes some sales and view the best sellers report.

you can view the code in question in the OrderReportService.cs file at line ~368

version: 4.4


While I just mention this bug for the best sellers report, it might be a good idea to make sure other reports do not have the same issue.
3 years ago
Thanks for highlighting this - I would copy & paste this as as a bug/issue on Github. NopCommerce team will create a work item for 4.4 release.  -Edit: actually this is in the bug report Forum.  Will get picked up!





YetAnotherDeveloper wrote:
I was doing an update from 3.x to 4.4 and as I was smoke testing the upgrade in a test environment i noticed that the reports for best selling products was wrong. A quick glance showed that for some of my products their sales were being doubled. I doubled checked the data in the database and it all seems to be correct.  I started to debug the code, at some point in the past someone added in the Category to the query for the best seller report and because of that left join it will count your sales 1 time for each category that product is in.  in my case i had a few of my best sellers in two categories and there for my sales were doubled for them.

I would assume that sales for an order item should be counted only once, no matter how many categories that product is in.

to reproduce just add a couple categories to a product, makes some sales and view the best sellers report.

you can view the code in question in the OrderReportService.cs file at line ~368

version: 4.4


While I just mention this bug for the best sellers report, it might be a good idea to make sure other reports do not have the same issue.
3 years ago
Thanks.
Here is a work item for this issue.
3 years ago
Done. You can see changes here.
3 years ago
Dmitry,

Thank you for the fix for best sellers. Just applied your changes and it works. However, i noticed no one mentioned this same issue is also affecting "products never purchased" report. For each product in the list is duplicated based on how many categories are assigned to each product.

Example, 2 categories, 2 product entries. 5 categories, 5 product entries, etc.
3 years ago
Thanks for the bug report. Work item here.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.