Skip to content

Commit f951933

Browse files
akaplyavaldislav
authored andcommitted
MAGETWO-36882: Stabilizing branch
1 parent 335d7ff commit f951933

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

app/code/Magento/Sales/Model/Resource/Order.php

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,19 @@ public function __construct(
8888
*/
8989
public function aggregateProductsByTypes($orderId, $productTypeIds = [], $isProductTypeIn = false)
9090
{
91-
// $adapter = $this->getReadConnection();
92-
// $select = $adapter->select()->from(
93-
// ['o' => $this->getTable('sales_order_item')],
94-
// ['o.product_type', new \Zend_Db_Expr('COUNT(*)')]
95-
// )->joinInner(
96-
// ['p' => $this->getTable('catalog_product_entity')],
97-
// 'o.product_id=p.entity_id',
98-
// []
99-
// )->where(
100-
// 'o.order_id=?',
101-
// $orderId
102-
// )->group(
103-
// 'o.product_type'
104-
// );
105-
// if ($productTypeIds) {
106-
// $select->where(sprintf('(o.product_type %s (?))', $isProductTypeIn ? 'IN' : 'NOT IN'), $productTypeIds);
107-
// }
108-
// return $adapter->fetchPairs($select);
109-
return [];
91+
$adapter = $this->getReadConnection();
92+
$select = $adapter->select()
93+
->from(
94+
['o' => $this->getTable('sales_order_item')],
95+
['o.product_type', new \Zend_Db_Expr('COUNT(*)')]
96+
)
97+
->where('o.order_id=?', $orderId)
98+
->where('o.product_id IS NOT NULL')
99+
->group('o.product_type');
100+
if ($productTypeIds) {
101+
$select->where(sprintf('(o.product_type %s (?))', $isProductTypeIn ? 'IN' : 'NOT IN'), $productTypeIds);
102+
}
103+
return $adapter->fetchPairs($select);
110104
}
111105

112106
/**

app/code/Magento/Sales/Model/Resource/Order/Status.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\SalesSequence\Model\Manager;
1212
use \Magento\Sales\Model\Resource\EntityAbstract;
1313
use \Magento\Sales\Model\Resource\EntitySnapshot;
14+
1415
/**
1516
* Order status resource model
1617
*
@@ -62,7 +63,8 @@ public function __construct(
6263
$sequenceManager,
6364
$entitySnapshot,
6465
$resourcePrefix,
65-
$gridAggregator);
66+
$gridAggregator
67+
);
6668
}
6769

6870
/**

app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ public function aggregate($from = null, $to = null)
135135
'store_id' => 'source_table.store_id',
136136
'product_id' => 'order_item.product_id',
137137
'product_name' => new \Zend_Db_Expr('MIN(order_item.name)'),
138-
'product_price' => new \Zend_Db_Expr('MIN(order_item.base_price) * MIN(source_table.base_to_global_rate)'),
138+
'product_price' => new \Zend_Db_Expr(
139+
'MIN(order_item.base_price) * MIN(source_table.base_to_global_rate)'
140+
),
139141
'qty_ordered' => new \Zend_Db_Expr('SUM(order_item.qty_ordered)'),
140142
];
141143

@@ -150,7 +152,8 @@ public function aggregate($from = null, $to = null)
150152
'source_table.state != ?',
151153
\Magento\Sales\Model\Order::STATE_CANCELED
152154
)->where(
153-
'order_item.product_type NOT IN(?)', $this->ignoredProductTypes
155+
'order_item.product_type NOT IN(?)',
156+
$this->ignoredProductTypes
154157
);
155158

156159
if ($subSelect !== null) {

0 commit comments

Comments
 (0)