From 5d30662c7603c4ab00d4952a3ccf454888cc9a17 Mon Sep 17 00:00:00 2001 From: Serhii Balko Date: Tue, 16 Apr 2019 14:06:02 +0300 Subject: [PATCH 1/9] MAGETWO-98899: Special Prices cannot save over 4 characters in Japanese Yen - The comma separator seems to be the issue --- .../Magento/Framework/Locale/Format.php | 31 ++++++++++++++++++- .../Framework/Locale/Test/Unit/FormatTest.php | 24 ++++++++++---- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/lib/internal/Magento/Framework/Locale/Format.php b/lib/internal/Magento/Framework/Locale/Format.php index adcffe01b910e..a66f14260c9cb 100644 --- a/lib/internal/Magento/Framework/Locale/Format.php +++ b/lib/internal/Magento/Framework/Locale/Format.php @@ -25,6 +25,11 @@ class Format implements \Magento\Framework\Locale\FormatInterface */ protected $currencyFactory; + /** + * @var array + */ + private $groupSeparatorByLocale = []; + /** * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param ResolverInterface $localeResolver @@ -81,7 +86,13 @@ public function getNumber($value) $value = str_replace(',', '', $value); } } elseif ($separatorComa !== false) { - $value = str_replace(',', '.', $value); + $locale = $this->_localeResolver->getLocale(); + $groupSeparator = $this->retrieveLocaleGroupSeparator($locale); + if ($groupSeparator === ',') { + $value = str_replace(',', '', $value); + } else { + $value = str_replace(',', '.', $value); + } } return (float)$value; @@ -149,4 +160,22 @@ public function getPriceFormat($localeCode = null, $currencyCode = null) return $result; } + + /** + * Retrieve group separator symbol by locale + * + * @param string $locale + * @return string + */ + private function retrieveLocaleGroupSeparator(string $locale): string + { + if (!array_key_exists($locale, $this->groupSeparatorByLocale)) { + $formatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL); + $this->groupSeparatorByLocale[$locale] = $formatter->getSymbol( + \NumberFormatter::GROUPING_SEPARATOR_SYMBOL + ); + } + + return $this->groupSeparatorByLocale[$locale]; + } } diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/FormatTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/FormatTest.php index f6d7326f52764..09b6d982c252d 100644 --- a/lib/internal/Magento/Framework/Locale/Test/Unit/FormatTest.php +++ b/lib/internal/Magento/Framework/Locale/Test/Unit/FormatTest.php @@ -6,6 +6,9 @@ namespace Magento\Framework\Locale\Test\Unit; +/** + * Tests class for Number locale format + */ class FormatTest extends \PHPUnit\Framework\TestCase { /** @@ -84,21 +87,26 @@ public function testGetPriceFormat($localeCode, $expectedResult) */ public function getPriceFormatDataProvider() { + $swissGroupSymbol = INTL_ICU_VERSION >= 59.1 ? '’' : '\''; return [ ['en_US', ['decimalSymbol' => '.', 'groupSymbol' => ',']], ['de_DE', ['decimalSymbol' => ',', 'groupSymbol' => '.']], - ['de_CH', ['decimalSymbol' => '.', 'groupSymbol' => '\'']], + ['de_CH', ['decimalSymbol' => '.', 'groupSymbol' => $swissGroupSymbol]], ['uk_UA', ['decimalSymbol' => ',', 'groupSymbol' => ' ']] ]; } /** - * @param float | null $expected * @param string|float|int $value + * @param float | null $expected + * @param string $locale * @dataProvider provideNumbers */ - public function testGetNumber($value, $expected) + public function testGetNumber(string $value, float $expected, string $locale = null) { + if ($locale !== null) { + $this->localeResolver->method('getLocale')->willReturn($locale); + } $this->assertEquals($expected, $this->formatModel->getNumber($value)); } @@ -113,11 +121,15 @@ public function provideNumbers(): array ['12343', 12343], ['-9456km', -9456], ['0', 0], - ['2 054,10', 2054.1], - ['2046,45', 2046.45], + ['2 054,10', 205410, 'en_US'], + ['2 054,10', 2054.1, 'de_DE'], + ['2046,45', 204645, 'en_US'], + ['2046,45', 2046.45, 'de_DE'], ['2 054.52', 2054.52], - ['2,46 GB', 2.46], + ['2,46 GB', 246, 'en_US'], + ['2,46 GB', 2.46, 'de_DE'], ['2,054.00', 2054], + ['2,000', 2000, 'ja_JP'], ]; } } From cd05ead490d1a31f49a9feed7f7915f061a1f499 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha Date: Tue, 16 Apr 2019 21:56:27 +0300 Subject: [PATCH 2/9] MAGETWO-98700: Shared catalog configurable product with out of stock options and instock options loads with empty drop down for non logged in customers --- .../ActionGroup/AdminProductActionGroup.xml | 6 +++++ .../StorefrontCategoryProductSection.xml | 1 + .../Mftf/Data/CatalogInventoryConfigData.xml | 23 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 app/code/Magento/CatalogInventory/Test/Mftf/Data/CatalogInventoryConfigData.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml index e68c75858102f..606d63825b660 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml @@ -269,4 +269,10 @@ + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml index ccb5ae60db59b..275021302a4d2 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml @@ -24,5 +24,6 @@ + diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/Data/CatalogInventoryConfigData.xml b/app/code/Magento/CatalogInventory/Test/Mftf/Data/CatalogInventoryConfigData.xml new file mode 100644 index 0000000000000..e14c36446fc2b --- /dev/null +++ b/app/code/Magento/CatalogInventory/Test/Mftf/Data/CatalogInventoryConfigData.xml @@ -0,0 +1,23 @@ + + + + + + cataloginventory/options/show_out_of_stock + 0 + Yes + 1 + + + cataloginventory/options/show_out_of_stock + 0 + No + 0 + + From 1443ee2c8de1d761bf77c3f31f7e5b6bb12b98c6 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha Date: Wed, 17 Apr 2019 00:35:01 +0300 Subject: [PATCH 3/9] MAGETWO-98700: Shared catalog configurable product with out of stock options and instock options loads with empty drop down for non logged in customers --- .../Test/Mftf/ActionGroup/AdminProductActionGroup.xml | 11 +++++------ .../Mftf/Section/StorefrontCategoryProductSection.xml | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml index 606d63825b660..89d9cf8fe2822 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml @@ -248,15 +248,14 @@ - + - - - - + + + @@ -269,7 +268,7 @@ - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml index 275021302a4d2..ceec6839f6381 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml @@ -24,6 +24,6 @@ - + From 4a88bfd0ce0591956bf1724a34ab034e85a06650 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha Date: Wed, 17 Apr 2019 04:45:34 +0300 Subject: [PATCH 4/9] MAGETWO-98700: Shared catalog configurable product with out of stock options and instock options loads with empty drop down for non logged in customers --- .../Test/Mftf/Section/StorefrontCategoryProductSection.xml | 2 +- .../AdminCreateApiConfigurableProductActionGroup.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml index ceec6839f6381..26c9035d6b136 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml @@ -24,6 +24,6 @@ - + diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminCreateApiConfigurableProductActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminCreateApiConfigurableProductActionGroup.xml index cdb147e99ad58..abbef02adc520 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminCreateApiConfigurableProductActionGroup.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminCreateApiConfigurableProductActionGroup.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - + From f9fe45dc36238f07b79324f860391a99b27f953e Mon Sep 17 00:00:00 2001 From: Yurii Sapiha Date: Wed, 17 Apr 2019 21:57:19 +0300 Subject: [PATCH 5/9] MAGETWO-98700: Shared catalog configurable product with out of stock options and instock options loads with empty drop down for non logged in customers --- .../Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml index 89d9cf8fe2822..ba50a0974ec87 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml @@ -251,11 +251,11 @@ - - + + From 27bb13c4c5c612d26ffc8622732ffc05615f839a Mon Sep 17 00:00:00 2001 From: Serhii Balko Date: Thu, 18 Apr 2019 13:21:47 +0300 Subject: [PATCH 6/9] MAGETWO-98899: Special Prices cannot save over 4 characters in Japanese Yen - The comma separator seems to be the issue --- .../Magento/Framework/Locale/Format.php | 43 ++++++------------- .../Framework/Locale/Test/Unit/FormatTest.php | 13 +++--- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/lib/internal/Magento/Framework/Locale/Format.php b/lib/internal/Magento/Framework/Locale/Format.php index a66f14260c9cb..c5e9ad26a25e1 100644 --- a/lib/internal/Magento/Framework/Locale/Format.php +++ b/lib/internal/Magento/Framework/Locale/Format.php @@ -10,6 +10,11 @@ */ class Format implements \Magento\Framework\Locale\FormatInterface { + /** + * Japan locale code + */ + private static $japanLocaleCode = 'ja_JP'; + /** * @var \Magento\Framework\App\ScopeResolverInterface */ @@ -25,11 +30,6 @@ class Format implements \Magento\Framework\Locale\FormatInterface */ protected $currencyFactory; - /** - * @var array - */ - private $groupSeparatorByLocale = []; - /** * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param ResolverInterface $localeResolver @@ -87,12 +87,15 @@ public function getNumber($value) } } elseif ($separatorComa !== false) { $locale = $this->_localeResolver->getLocale(); - $groupSeparator = $this->retrieveLocaleGroupSeparator($locale); - if ($groupSeparator === ',') { - $value = str_replace(',', '', $value); - } else { - $value = str_replace(',', '.', $value); - } + /** + * It's hard code for Japan locale. + * The comma separator uses as group separator: 4,000 saves as 4,000.00 + */ + $value = str_replace( + ',', + $locale === self::$japanLocaleCode ? '' : '.', + $value + ); } return (float)$value; @@ -160,22 +163,4 @@ public function getPriceFormat($localeCode = null, $currencyCode = null) return $result; } - - /** - * Retrieve group separator symbol by locale - * - * @param string $locale - * @return string - */ - private function retrieveLocaleGroupSeparator(string $locale): string - { - if (!array_key_exists($locale, $this->groupSeparatorByLocale)) { - $formatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL); - $this->groupSeparatorByLocale[$locale] = $formatter->getSymbol( - \NumberFormatter::GROUPING_SEPARATOR_SYMBOL - ); - } - - return $this->groupSeparatorByLocale[$locale]; - } } diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/FormatTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/FormatTest.php index 09b6d982c252d..8c8e118aa3169 100644 --- a/lib/internal/Magento/Framework/Locale/Test/Unit/FormatTest.php +++ b/lib/internal/Magento/Framework/Locale/Test/Unit/FormatTest.php @@ -111,6 +111,7 @@ public function testGetNumber(string $value, float $expected, string $locale = n } /** + * * @return array */ public function provideNumbers(): array @@ -121,15 +122,13 @@ public function provideNumbers(): array ['12343', 12343], ['-9456km', -9456], ['0', 0], - ['2 054,10', 205410, 'en_US'], - ['2 054,10', 2054.1, 'de_DE'], - ['2046,45', 204645, 'en_US'], - ['2046,45', 2046.45, 'de_DE'], + ['2 054,10', 2054.1], + ['2046,45', 2046.45], ['2 054.52', 2054.52], - ['2,46 GB', 246, 'en_US'], - ['2,46 GB', 2.46, 'de_DE'], + ['2,46 GB', 2.46], ['2,054.00', 2054], - ['2,000', 2000, 'ja_JP'], + ['4,000', 4000.0, 'ja_JP'], + ['4,000', 4.0, 'en_US'], ]; } } From 60d754238e00cb4f03759b0b16f2792b16669a0f Mon Sep 17 00:00:00 2001 From: Mastiuhin Olexandr Date: Tue, 23 Apr 2019 13:20:00 +0300 Subject: [PATCH 7/9] MAGETWO-97413: [Magento Cloud] Grouped Products lose the associated SKUs after scheduled update expires --- .../ActionGroup/AdminProductActionGroup.xml | 8 ++++++++ ...resenceOnGroupedProductPageActionGroup.xml | 19 +++++++++++++++++++ .../StorefrontProductInfoMainSection.xml | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 app/code/Magento/GroupedProduct/Test/Mftf/ActionGroup/AssertLinkPresenceOnGroupedProductPageActionGroup.xml create mode 100644 app/code/Magento/GroupedProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml index e68c75858102f..3dfdd76733f40 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml @@ -269,4 +269,12 @@ + + + + + + + + diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/ActionGroup/AssertLinkPresenceOnGroupedProductPageActionGroup.xml b/app/code/Magento/GroupedProduct/Test/Mftf/ActionGroup/AssertLinkPresenceOnGroupedProductPageActionGroup.xml new file mode 100644 index 0000000000000..bce78f8bf9961 --- /dev/null +++ b/app/code/Magento/GroupedProduct/Test/Mftf/ActionGroup/AssertLinkPresenceOnGroupedProductPageActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml new file mode 100644 index 0000000000000..45d8e63343734 --- /dev/null +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml @@ -0,0 +1,14 @@ + + + + +
+ +
+
From d4b7eda00c2cdf144baf35c42379efdc8d66d0a9 Mon Sep 17 00:00:00 2001 From: Serhii Balko Date: Wed, 24 Apr 2019 17:16:54 +0300 Subject: [PATCH 8/9] MAGETWO-98899: Special Prices cannot save over 4 characters in Japanese Yen - The comma separator seems to be the issue --- .../Backend/TierPrice/UpdateHandler.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php index 500e59f26a2c3..bda92fbeab9ed 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php @@ -5,8 +5,9 @@ */ namespace Magento\Catalog\Model\Product\Attribute\Backend\TierPrice; -use Magento\Framework\EntityManager\Operation\ExtensionInterface; use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Locale\FormatInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\Catalog\Api\ProductAttributeRepositoryInterface; use Magento\Customer\Api\GroupManagementInterface; @@ -38,19 +39,26 @@ class UpdateHandler extends AbstractHandler */ private $tierPriceResource; + /** + * @var FormatInterface + */ + private $localeFormat; + /** * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository * @param \Magento\Customer\Api\GroupManagementInterface $groupManagement * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool * @param \Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice $tierPriceResource + * @param FormatInterface|null $localeFormat */ public function __construct( StoreManagerInterface $storeManager, ProductAttributeRepositoryInterface $attributeRepository, GroupManagementInterface $groupManagement, MetadataPool $metadataPool, - Tierprice $tierPriceResource + Tierprice $tierPriceResource, + FormatInterface $localeFormat = null ) { parent::__construct($groupManagement); @@ -58,6 +66,7 @@ public function __construct( $this->attributeRepository = $attributeRepository; $this->metadataPoll = $metadataPool; $this->tierPriceResource = $tierPriceResource; + $this->localeFormat = $localeFormat ?: ObjectManager::getInstance()->get(FormatInterface::class); } /** @@ -116,8 +125,9 @@ private function updateValues(array $valuesToUpdate, array $oldValues): bool { $isChanged = false; foreach ($valuesToUpdate as $key => $value) { - if ((!empty($value['value']) && (float)$oldValues[$key]['price'] !== (float)$value['value']) - || $this->getPercentage($oldValues[$key]) !== $this->getPercentage($value) + if ((!empty($value['value']) + && (float)$oldValues[$key]['price'] !== $this->localeFormat->getNumber($value['value']) + ) || $this->getPercentage($oldValues[$key]) !== $this->getPercentage($value) ) { $price = new \Magento\Framework\DataObject( [ From 0abb1374763b8135dc53e8e9abdf24572543c5af Mon Sep 17 00:00:00 2001 From: Serhii Balko Date: Thu, 2 May 2019 10:20:16 +0300 Subject: [PATCH 9/9] MAGETWO-91328: Checkout doesn't work when AdBlock extension enabled and Google Analytics is enabled --- lib/web/mage/requirejs/resolver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/mage/requirejs/resolver.js b/lib/web/mage/requirejs/resolver.js index 588a0f8411cff..5ba1f1351bcf6 100644 --- a/lib/web/mage/requirejs/resolver.js +++ b/lib/web/mage/requirejs/resolver.js @@ -34,7 +34,7 @@ define([ * @return {Boolean} */ function isRejected(module) { - return registry[module.id] && registry[module.id].error; + return registry[module.id] && (registry[module.id].inited || registry[module.id].error); } /**