Skip to content

Commit 42c03f7

Browse files
committed
ACP2E-420: Price in a Scheduled Update divided by 1000 depending on the Locale
1 parent b6462bd commit 42c03f7

File tree

6 files changed

+19
-65
lines changed

6 files changed

+19
-65
lines changed

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@
825825
<data key="name" unique="suffix">VirtualProduct</data>
826826
<data key="sku" unique="suffix">virtual_sku</data>
827827
<data key="price">9000.00</data>
828-
<data key="formattedPrice">9,000.00</data>
829828
<data key="quantity">999</data>
830829
<data key="status">In Stock</data>
831830
<data key="visibility">Catalog, Search</data>
@@ -847,7 +846,6 @@
847846
<data key="name" unique="suffix">VirtualProduct</data>
848847
<data key="sku" unique="suffix">virtual_sku</data>
849848
<data key="price">9000.00</data>
850-
<data key="formattedPrice">9,000.00</data>
851849
<data key="quantity">999</data>
852850
<data key="status">Out of Stock</data>
853851
<data key="visibility">Catalog, Search</data>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductOutOfStockWithTierPriceTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
</assertEquals>
9898
<grabTextFrom selector="{{StorefrontProductInfoMainSection.productPrice}}" stepKey="productPriceAmount"/>
9999
<assertEquals stepKey="assertOldPriceTextOnProductPage">
100-
<expectedResult type="string">${{virtualProductOutOfStock.formattedPrice}}</expectedResult>
100+
<expectedResult type="string">${{virtualProductOutOfStock.price}}</expectedResult>
101101
<actualResult type="variable">productPriceAmount</actualResult>
102102
</assertEquals>
103103
</test>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
</assertEquals>
151151
<grabTextFrom selector="{{StorefrontProductInfoMainSection.productPrice}}" stepKey="productPriceAmount"/>
152152
<assertEquals stepKey="assertOldPriceTextOnProductPage">
153-
<expectedResult type="string">${{virtualProductCustomImportOptions.formattedPrice}}</expectedResult>
153+
<expectedResult type="string">${{virtualProductCustomImportOptions.price}}</expectedResult>
154154
<actualResult type="variable">productPriceAmount</actualResult>
155155
</assertEquals>
156156

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ class CustomOptions extends AbstractModifier
137137
*/
138138
protected $meta = [];
139139

140-
/**
141-
* @var CurrencyInterface
142-
*/
143-
private $localeCurrency;
144-
145140
/**
146141
* @param LocatorInterface $locator
147142
* @param StoreManagerInterface $storeManager
@@ -1183,22 +1178,7 @@ protected function getCurrencySymbol()
11831178
}
11841179

11851180
/**
1186-
* The getter function to get the locale currency for real application code
1187-
*
1188-
* @return \Magento\Framework\Locale\CurrencyInterface
1189-
*
1190-
* @deprecated 101.0.0
1191-
*/
1192-
private function getLocaleCurrency()
1193-
{
1194-
if ($this->localeCurrency === null) {
1195-
$this->localeCurrency = \Magento\Framework\App\ObjectManager::getInstance()->get(CurrencyInterface::class);
1196-
}
1197-
return $this->localeCurrency;
1198-
}
1199-
1200-
/**
1201-
* Format price according to the locale of the currency
1181+
* Format price
12021182
*
12031183
* @param mixed $value
12041184
* @return string
@@ -1210,9 +1190,11 @@ protected function formatPrice($value)
12101190
return null;
12111191
}
12121192

1213-
$store = $this->storeManager->getStore();
1214-
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
1215-
$value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
1193+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
1194+
$roundValue = call_user_func([\Zend_Locale_Math::class, 'round'], $value, 2);
1195+
1196+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
1197+
$value = call_user_func([\Zend_Locale_Math::class, 'normalize'], $roundValue);
12161198

12171199
return $value;
12181200
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
class Eav extends AbstractModifier
5454
{
5555
public const SORT_ORDER_MULTIPLIER = 10;
56-
public const PRECISION = 2;
5756

5857
/**
5958
* @var LocatorInterface
@@ -1108,7 +1107,7 @@ protected function formatPrice($value)
11081107
}
11091108

11101109
// phpcs:ignore Magento2.Functions.DiscouragedFunction
1111-
$roundValue = call_user_func([\Zend_Locale_Math::class, 'round'], $value, self::PRECISION);
1110+
$roundValue = call_user_func([\Zend_Locale_Math::class, 'round'], $value, 2);
11121111

11131112
// phpcs:ignore Magento2.Functions.DiscouragedFunction
11141113
$value = call_user_func([\Zend_Locale_Math::class, 'normalize'], $roundValue);

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class General extends AbstractModifier
3232
*/
3333
protected $arrayManager;
3434

35-
/**
36-
* @var \Magento\Framework\Locale\CurrencyInterface
37-
*/
38-
private $localeCurrency;
39-
4035
/**
4136
* @var AttributeRepositoryInterface
4237
*/
@@ -417,23 +412,7 @@ protected function customizeNameListeners(array $meta)
417412
}
418413

419414
/**
420-
* The getter function to get the locale currency for real application code
421-
*
422-
* @return \Magento\Framework\Locale\CurrencyInterface
423-
*
424-
* @deprecated 101.0.0
425-
*/
426-
private function getLocaleCurrency()
427-
{
428-
if ($this->localeCurrency === null) {
429-
$this->localeCurrency = \Magento\Framework\App\ObjectManager::getInstance()
430-
->get(\Magento\Framework\Locale\CurrencyInterface::class);
431-
}
432-
return $this->localeCurrency;
433-
}
434-
435-
/**
436-
* Format price according to the locale of the currency
415+
* Format price
437416
*
438417
* @param mixed $value
439418
* @return string
@@ -445,15 +424,16 @@ protected function formatPrice($value)
445424
return null;
446425
}
447426

448-
$store = $this->locator->getStore();
449-
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
450-
$value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
427+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
428+
$roundValue = call_user_func([\Zend_Locale_Math::class, 'round'], $value, 2);
429+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
430+
$value = call_user_func([\Zend_Locale_Math::class, 'normalize'], $roundValue);
451431

452432
return $value;
453433
}
454434

455435
/**
456-
* Format number according to the locale of the currency and precision of input
436+
* Format number according precision of input
457437
*
458438
* @param mixed $value
459439
* @return string
@@ -467,15 +447,10 @@ protected function formatNumber($value)
467447

468448
$value = (float)$value;
469449
$precision = strlen(substr(strrchr($value, "."), 1));
470-
$store = $this->locator->getStore();
471-
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
472-
$value = $currency->toCurrency(
473-
$value,
474-
[
475-
'display' => \Magento\Framework\Currency::NO_SYMBOL,
476-
'precision' => $precision
477-
]
478-
);
450+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
451+
$roundValue = call_user_func([\Zend_Locale_Math::class, 'round'], $value, $precision);
452+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
453+
$value = call_user_func([\Zend_Locale_Math::class, 'normalize'], $roundValue);
479454

480455
return $value;
481456
}

0 commit comments

Comments
 (0)