diff --git a/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php b/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php
index f370c49cdfa20..e0a92ea0e0bea 100644
--- a/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php
+++ b/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php
@@ -115,7 +115,8 @@ protected function wrapResult($html)
{
return '
getSaleableItem()->getId() . '"' .
+ 'data-product-id="' . $this->getSaleableItem()->getId() . '" ' .
+ 'data-price-box="product-id-' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '
';
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php
index fc45a2e0c2146..6322fc76ff442 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php
@@ -246,7 +246,8 @@ public function testRenderMsrpEnabled()
//assert price wrapper
$this->assertEquals(
- 'test
',
+ 'test
',
$result
);
}
diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
index b5d02f64e6eb5..f9a6b12992386 100644
--- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
+++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
@@ -67,7 +67,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
/**
* @var Format
*/
- private $localeFormat;
+ protected $localeFormat;
/**
* @var Session
@@ -211,9 +211,6 @@ public function getJsonConfig()
$store = $this->getCurrentStore();
$currentProduct = $this->getProduct();
- $regularPrice = $currentProduct->getPriceInfo()->getPrice('regular_price');
- $finalPrice = $currentProduct->getPriceInfo()->getPrice('final_price');
-
$options = $this->helper->getOptions($currentProduct, $this->getAllowProducts());
$attributesData = $this->configurableAttributeData->getAttributesData($currentProduct, $options);
@@ -223,17 +220,7 @@ public function getJsonConfig()
'currencyFormat' => $store->getCurrentCurrency()->getOutputFormat(),
'optionPrices' => $this->getOptionPrices(),
'priceFormat' => $this->localeFormat->getPriceFormat(),
- 'prices' => [
- 'oldPrice' => [
- 'amount' => $this->localeFormat->getNumber($regularPrice->getAmount()->getValue()),
- ],
- 'basePrice' => [
- 'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getBaseAmount()),
- ],
- 'finalPrice' => [
- 'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getValue()),
- ],
- ],
+ 'prices' => $this->getPrices(),
'productId' => $currentProduct->getId(),
'chooseText' => __('Choose an Option...'),
'images' => $this->getOptionImages(),
@@ -248,6 +235,32 @@ public function getJsonConfig()
return $this->jsonEncoder->encode($config);
}
+
+ /**
+ * Get product prices for configurable variations
+ *
+ * @return array
+ * @since 100.2.0
+ */
+ protected function getPrices()
+ {
+ $currentProduct = $this->getProduct();
+
+ $regularPrice = $currentProduct->getPriceInfo()->getPrice('regular_price');
+ $finalPrice = $currentProduct->getPriceInfo()->getPrice('final_price');
+
+ return [
+ 'oldPrice' => [
+ 'amount' => $this->localeFormat->getNumber($regularPrice->getAmount()->getValue()),
+ ],
+ 'basePrice' => [
+ 'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getBaseAmount()),
+ ],
+ 'finalPrice' => [
+ 'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getValue()),
+ ],
+ ];
+ }
/**
* Get product images for configurable variations
diff --git a/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php b/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php
index 6a42ad1cc9849..54943498ee629 100644
--- a/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php
+++ b/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php
@@ -66,6 +66,26 @@ public function getJsonConfig()
$this->unsetData('allow_products');
return parent::getJsonConfig();
}
+
+ /**
+ * Composes configuration for js price format
+ *
+ * @return string
+ */
+ public function getPriceFormatJson()
+ {
+ return $this->jsonEncoder->encode($this->localeFormat->getPriceFormat());
+ }
+
+ /**
+ * Composes configuration for js price
+ *
+ * @return string
+ */
+ public function getPricesJson()
+ {
+ return $this->jsonEncoder->encode($this->getPrices());
+ }
/**
* Do not load images for Configurable product with swatches due to its loaded by request
diff --git a/app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml b/app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml
index 75a39a0e4e270..f8c55d6426982 100644
--- a/app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml
+++ b/app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml
@@ -4,37 +4,38 @@
* See COPYING.txt for license details.
*/
?>
-
-
-
- priceBoxes.priceBox({
- 'priceConfig': {
- priceFormat: jsonConfig.priceFormat,
- prices: jsonConfig.prices
+