1414use Magento \Quote \Model \Quote \Item ;
1515use Magento \Framework \Pricing \Helper \Data ;
1616use Magento \Framework \Serialize \SerializerInterface ;
17+ use Magento \Bundle \Model \Product \OriginalPrice ;
1718
1819/**
1920 * Data provider for bundled product options
@@ -25,39 +26,23 @@ class BundleOptionDataProvider
2526 */
2627 private const OPTION_TYPE = 'bundle ' ;
2728
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-
4329 /** @var Uid */
4430 private $ uidEncoder ;
4531
4632 /**
4733 * @param Data $pricingHelper
4834 * @param SerializerInterface $serializer
4935 * @param Configuration $configuration
36+ * @param OriginalPrice $originalPrice
5037 * @param Uid|null $uidEncoder
5138 */
5239 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 ,
5644 Uid $ uidEncoder = null
5745 ) {
58- $ this ->pricingHelper = $ pricingHelper ;
59- $ this ->serializer = $ serializer ;
60- $ this ->configuration = $ configuration ;
6146 $ this ->uidEncoder = $ uidEncoder ?: ObjectManager::getInstance ()
6247 ->get (Uid::class);
6348 }
@@ -139,28 +124,34 @@ private function buildBundleOptionValues(array $selections, Item $item): array
139124 $ values = [];
140125
141126 $ product = $ item ->getProduct ();
127+ $ currencyCode = $ item ->getQuote ()->getQuoteCurrencyCode ();
142128 foreach ($ selections as $ selection ) {
143129 $ qty = (float ) $ this ->configuration ->getSelectionQty ($ product , $ selection ->getSelectionId ());
144130 if (!$ qty ) {
145131 continue ;
146132 }
147-
148133 $ selectionPrice = $ this ->configuration ->getSelectionFinalPrice ($ item , $ selection );
149134 $ optionDetails = [
150135 self ::OPTION_TYPE ,
151136 $ selection ->getData ('option_id ' ),
152137 $ selection ->getData ('selection_id ' ),
153138 (int ) $ selection ->getData ('selection_qty ' )
154139 ];
140+ $ price = $ this ->pricingHelper ->currency ($ selectionPrice , false , false );
155141 $ values [] = [
156142 'id ' => $ selection ->getSelectionId (),
157143 'uid ' => $ this ->uidEncoder ->encode (implode ('/ ' , $ optionDetails )),
158144 'label ' => $ selection ->getName (),
159145 '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+ ],
161153 ];
162154 }
163-
164155 return $ values ;
165156 }
166157}
0 commit comments