7
7
8
8
namespace Magento \Quote \Model \Quote ;
9
9
10
+ use Magento \Framework \App \ObjectManager ;
10
11
use Magento \Quote \Model \Quote \Address \Total \Collector ;
11
12
use Magento \Quote \Model \Quote \Address \Total \CollectorFactory ;
12
13
use Magento \Quote \Model \Quote \Address \Total \CollectorInterface ;
13
14
14
15
/**
15
- * Class TotalsCollector
16
+ * Composite object for collecting total.
16
17
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17
18
*/
18
19
class TotalsCollector
@@ -68,6 +69,11 @@ class TotalsCollector
68
69
*/
69
70
protected $ shippingAssignmentFactory ;
70
71
72
+ /**
73
+ * @var QuantityCollector
74
+ */
75
+ private $ quantityCollector ;
76
+
71
77
/**
72
78
* @param Collector $totalCollector
73
79
* @param CollectorFactory $totalCollectorFactory
@@ -78,6 +84,7 @@ class TotalsCollector
78
84
* @param \Magento\Quote\Model\ShippingFactory $shippingFactory
79
85
* @param \Magento\Quote\Model\ShippingAssignmentFactory $shippingAssignmentFactory
80
86
* @param \Magento\Quote\Model\QuoteValidator $quoteValidator
87
+ * @param QuantityCollector $quantityCollector
81
88
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
82
89
*/
83
90
public function __construct (
@@ -89,7 +96,8 @@ public function __construct(
89
96
\Magento \Quote \Model \Quote \TotalsCollectorList $ collectorList ,
90
97
\Magento \Quote \Model \ShippingFactory $ shippingFactory ,
91
98
\Magento \Quote \Model \ShippingAssignmentFactory $ shippingAssignmentFactory ,
92
- \Magento \Quote \Model \QuoteValidator $ quoteValidator
99
+ \Magento \Quote \Model \QuoteValidator $ quoteValidator ,
100
+ QuantityCollector $ quantityCollector = null
93
101
) {
94
102
$ this ->totalCollector = $ totalCollector ;
95
103
$ this ->totalCollectorFactory = $ totalCollectorFactory ;
@@ -100,6 +108,8 @@ public function __construct(
100
108
$ this ->shippingFactory = $ shippingFactory ;
101
109
$ this ->shippingAssignmentFactory = $ shippingAssignmentFactory ;
102
110
$ this ->quoteValidator = $ quoteValidator ;
111
+ $ this ->quantityCollector = $ quantityCollector
112
+ ?: ObjectManager::getInstance ()->get (QuantityCollector::class);
103
113
}
104
114
105
115
/**
@@ -132,7 +142,7 @@ public function collect(\Magento\Quote\Model\Quote $quote)
132
142
['quote ' => $ quote ]
133
143
);
134
144
135
- $ this ->_collectItemsQtys ($ quote );
145
+ $ this ->quantityCollector -> collectItemsQtys ($ quote );
136
146
137
147
$ total ->setSubtotal (0 );
138
148
$ total ->setBaseSubtotal (0 );
@@ -206,6 +216,8 @@ protected function _validateCouponCode(\Magento\Quote\Model\Quote $quote)
206
216
*
207
217
* @param \Magento\Quote\Model\Quote $quote
208
218
* @return $this
219
+ * @deprecated
220
+ * @see \Magento\Quote\Model\Quote\QuantityCollector
209
221
*/
210
222
protected function _collectItemsQtys (\Magento \Quote \Model \Quote $ quote )
211
223
{
@@ -273,7 +285,7 @@ public function collectAddressTotals(
273
285
/** @var CollectorInterface $collector */
274
286
$ collector ->collect ($ quote , $ shippingAssignment , $ total );
275
287
}
276
-
288
+
277
289
$ this ->eventManager ->dispatch (
278
290
'sales_quote_address_collect_totals_after ' ,
279
291
[
0 commit comments