14
14
use Magento \Quote \Model \Quote \Item ;
15
15
use Magento \Framework \Pricing \Helper \Data ;
16
16
use Magento \Framework \Serialize \SerializerInterface ;
17
+ use Magento \Bundle \Model \Product \OriginalPrice ;
17
18
18
19
/**
19
20
* Data provider for bundled product options
@@ -25,39 +26,23 @@ class BundleOptionDataProvider
25
26
*/
26
27
private const OPTION_TYPE = 'bundle ' ;
27
28
28
- /**
29
- * @var Data
30
- */
31
- private $ pricingHelper ;
32
-
33
- /**
34
- * @var SerializerInterface
35
- */
36
- private $ serializer ;
37
-
38
- /**
39
- * @var Configuration
40
- */
41
- private $ configuration ;
42
-
43
29
/** @var Uid */
44
30
private $ uidEncoder ;
45
31
46
32
/**
47
33
* @param Data $pricingHelper
48
34
* @param SerializerInterface $serializer
49
35
* @param Configuration $configuration
36
+ * @param OriginalPrice $originalPrice
50
37
* @param Uid|null $uidEncoder
51
38
*/
52
39
public function __construct (
53
- Data $ pricingHelper ,
54
- SerializerInterface $ serializer ,
55
- Configuration $ configuration ,
40
+ private readonly Data $ pricingHelper ,
41
+ private readonly SerializerInterface $ serializer ,
42
+ private readonly Configuration $ configuration ,
43
+ private readonly OriginalPrice $ originalPrice ,
56
44
Uid $ uidEncoder = null
57
45
) {
58
- $ this ->pricingHelper = $ pricingHelper ;
59
- $ this ->serializer = $ serializer ;
60
- $ this ->configuration = $ configuration ;
61
46
$ this ->uidEncoder = $ uidEncoder ?: ObjectManager::getInstance ()
62
47
->get (Uid::class);
63
48
}
@@ -139,28 +124,34 @@ private function buildBundleOptionValues(array $selections, Item $item): array
139
124
$ values = [];
140
125
141
126
$ product = $ item ->getProduct ();
127
+ $ currencyCode = $ item ->getQuote ()->getQuoteCurrencyCode ();
142
128
foreach ($ selections as $ selection ) {
143
129
$ qty = (float ) $ this ->configuration ->getSelectionQty ($ product , $ selection ->getSelectionId ());
144
130
if (!$ qty ) {
145
131
continue ;
146
132
}
147
-
148
133
$ selectionPrice = $ this ->configuration ->getSelectionFinalPrice ($ item , $ selection );
149
134
$ optionDetails = [
150
135
self ::OPTION_TYPE ,
151
136
$ selection ->getData ('option_id ' ),
152
137
$ selection ->getData ('selection_id ' ),
153
138
(int ) $ selection ->getData ('selection_qty ' )
154
139
];
140
+ $ price = $ this ->pricingHelper ->currency ($ selectionPrice , false , false );
155
141
$ values [] = [
156
142
'id ' => $ selection ->getSelectionId (),
157
143
'uid ' => $ this ->uidEncoder ->encode (implode ('/ ' , $ optionDetails )),
158
144
'label ' => $ selection ->getName (),
159
145
'quantity ' => $ qty ,
160
- 'price ' => $ this ->pricingHelper ->currency ($ selectionPrice , false , false ),
146
+ 'price ' => $ price ,
147
+ 'priceV2 ' => ['currency ' => $ currencyCode , 'value ' => $ price ],
148
+ 'original_price ' => [
149
+ 'currency ' => $ currencyCode ,
150
+ 'value ' => $ this ->originalPrice
151
+ ->getSelectionOriginalPrice ($ item ->getProduct (), $ selection )
152
+ ],
161
153
];
162
154
}
163
-
164
155
return $ values ;
165
156
}
166
157
}
0 commit comments