Skip to content

Commit 148c5cd

Browse files
magento/magento2 magento#9196 - separated simple products of a configurable in product ordered report
1 parent 9485e36 commit 148c5cd

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

app/code/Magento/Reports/Model/ResourceModel/Product/Sold/Collection.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function setDateRange($from, $to)
4646
*/
4747
public function addOrderedQty($from = '', $to = '')
4848
{
49+
//return $this;
4950
$connection = $this->getConnection();
5051
$orderTableAliasName = $connection->quoteIdentifier('order');
5152

@@ -61,17 +62,15 @@ public function addOrderedQty($from = '', $to = '')
6162

6263
$this->getSelect()->reset()->from(
6364
['order_items' => $this->getTable('sales_order_item')],
64-
['ordered_qty' => 'SUM(order_items.qty_ordered)', 'order_items_name' => 'order_items.name']
65+
['ordered_qty' => 'order_items.qty_ordered', 'order_items_name' => 'order_items.name', 'order_items_sku' => 'order_items.sku']
6566
)->joinInner(
6667
['order' => $this->getTable('sales_order')],
6768
implode(' AND ', $orderJoinCondition),
6869
[]
6970
)->where(
7071
'parent_item_id IS NULL'
71-
)->group(
72-
'order_items.product_id'
7372
)->having(
74-
'SUM(order_items.qty_ordered) > ?',
73+
'order_items.qty_ordered > ?',
7574
0
7675
);
7776
return $this;

app/code/Magento/Reports/view/adminhtml/layout/reports_report_product_sold_grid.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141
<argument name="header_css_class" xsi:type="string">col-product</argument>
4242
</arguments>
4343
</block>
44+
<block class="Magento\Backend\Block\Widget\Grid\Column" as="sku">
45+
<arguments>
46+
<argument name="header" xsi:type="string" translate="true">SKU</argument>
47+
<argument name="type" xsi:type="string">text</argument>
48+
<argument name="index" xsi:type="string">order_items_sku</argument>
49+
<argument name="id" xsi:type="string">sku</argument>
50+
<argument name="column_css_class" xsi:type="string">col-sku</argument>
51+
<argument name="header_css_class" xsi:type="string">col-sku</argument>
52+
</arguments>
53+
</block>
4454
<block class="Magento\Backend\Block\Widget\Grid\Column" as="ordered_qty">
4555
<arguments>
4656
<argument name="header" xsi:type="string" translate="true">Ordered Quantity</argument>

0 commit comments

Comments
 (0)