From 9f9c76faf9a48bdea8b4737ca233a5c06280b3d9 Mon Sep 17 00:00:00 2001 From: Andrei Date: Fri, 17 Feb 2017 19:21:26 +0200 Subject: [PATCH 1/3] Fix #7371 'catalog_rule_price' is added to products only before load of the Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection and it is used only for detecting the minimal price here - Magento\Catalog\Pricing\Price\BasePrice. Due to it the price has never converted to the site currency. --- .../Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php b/app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php index 917cb37d9e180..43f3ec4631709 100644 --- a/app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php +++ b/app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php @@ -99,9 +99,9 @@ public function getValue() $this->product->getId() ); $this->value = $this->value ? floatval($this->value) : false; - if ($this->value) { - $this->value = $this->priceCurrency->convertAndRound($this->value); - } + } + if ($this->value) { + $this->value = $this->priceCurrency->convertAndRound($this->value); } } From 85ffb6017ed356a3d310fb5c69dc05ca205b9001 Mon Sep 17 00:00:00 2001 From: Andrei Date: Sun, 19 Feb 2017 01:38:09 +0200 Subject: [PATCH 2/3] Update getValueFromData test --- .../Test/Unit/Pricing/Price/CatalogRulePriceTest.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php b/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php index d3e72c37543c6..cdcec3aae9750 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php @@ -208,12 +208,20 @@ public function testGetValue() public function testGetValueFromData() { + $catalogRulePrice = 7.1; + $convertedPrice = 5.84; + + $this->priceCurrencyMock->expects($this->any()) + ->method('convertAndRound') + ->with($catalogRulePrice) + ->will($this->returnValue($convertedPrice)); + $this->saleableItemMock->expects($this->once())->method('hasData') ->with('catalog_rule_price')->willReturn(true); $this->saleableItemMock->expects($this->once())->method('getData') - ->with('catalog_rule_price')->willReturn('7.1'); + ->with('catalog_rule_price')->willReturn($catalogRulePrice); - $this->assertEquals(7.1, $this->object->getValue()); + $this->assertEquals($convertedPrice, $this->object->getValue()); } public function testGetAmountNoBaseAmount() From 92a6e89f97e68222565539d87c1006f93d155513 Mon Sep 17 00:00:00 2001 From: Andrei Date: Sun, 19 Feb 2017 22:16:44 +0200 Subject: [PATCH 3/3] fix whitespaces --- .../Test/Unit/Pricing/Price/CatalogRulePriceTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php b/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php index cdcec3aae9750..e17380c3f272b 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php @@ -210,12 +210,12 @@ public function testGetValueFromData() { $catalogRulePrice = 7.1; $convertedPrice = 5.84; - + $this->priceCurrencyMock->expects($this->any()) ->method('convertAndRound') ->with($catalogRulePrice) ->will($this->returnValue($convertedPrice)); - + $this->saleableItemMock->expects($this->once())->method('hasData') ->with('catalog_rule_price')->willReturn(true); $this->saleableItemMock->expects($this->once())->method('getData')