-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Component: ReportsEvent: dmcdindia1Fixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 release
Description
Preconditions (*)
- Magento 2.2.3
Steps to reproduce (*)
- In the Magento 2 admin go to Reports -> Products -> Ordered
- Select a date range where you know you have sold products spanning across multiple orders
- Select 'Show By' year
- Hit refresh
Expected result (*)
- I would expect to see a list of products sold per year, grouped by product with a total quantity
Actual result (*)
- I see a list of products sold per year, with multiple entries for a single product on a per order basis
Discussion
From what I can see in the source code, this still appears to be an issue in Magento 2.3.* and I can't see any related issues, if there are then please forgive me.
I have created a temporary patch file for this:
diff --git a/Model/ResourceModel/Product/Sold/Collection.php b/Model/ResourceModel/Product/Sold/Collection.php
index 61dc77d1..8b91fdb2 100644
--- a/Model/ResourceModel/Product/Sold/Collection.php
+++ b/Model/ResourceModel/Product/Sold/Collection.php
@@ -66,7 +66,7 @@ class Collection extends \Magento\Reports\Model\ResourceModel\Order\Collection
$this->getSelect()->reset()->from(
['order_items' => $this->getTable('sales_order_item')],
[
- 'ordered_qty' => 'order_items.qty_ordered',
+ 'ordered_qty' => 'SUM(order_items.qty_ordered)',
'order_items_name' => 'order_items.name',
'order_items_sku' => 'order_items.sku'
]
@@ -76,8 +76,10 @@ class Collection extends \Magento\Reports\Model\ResourceModel\Order\Collection
[]
)->where(
'order_items.parent_item_id IS NULL'
+ )->group(
+ 'order_items.product_id'
)->having(
- 'order_items.qty_ordered > ?',
+ 'SUM(order_items.qty_ordered) > ?',
0
);
return $this;
I will raise a PR if other people are experiencing this issue, any feedback would be welcome.
Regards,
Nick
Metadata
Metadata
Assignees
Labels
Component: ReportsEvent: dmcdindia1Fixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 release