Skip to content

Commit c7d18bd

Browse files
author
Stanislav Idolov
committed
MAGETWO-59512: [GitHub] Products in wishlist show $0.00 price #6866
1 parent 730b984 commit c7d18bd

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ class ConfigurableProduct extends FinalPrice implements ConfiguredPriceInterface
2121
*/
2222
public function getValue()
2323
{
24-
$result = 0.;
2524
/** @var \Magento\Wishlist\Model\Item\Option $customOption */
2625
$customOption = $this->getProduct()->getCustomOption('simple_product');
27-
if ($customOption) {
28-
/** @var \Magento\Framework\Pricing\PriceInfoInterface $priceInfo */
29-
$priceInfo = $customOption->getProduct()->getPriceInfo();
30-
$result = $priceInfo->getPrice(self::PRICE_CODE)->getValue();
31-
}
32-
return max(0, $result);
26+
$product = $customOption ? $customOption->getProduct() : $this->getProduct();
27+
$price = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getValue();
28+
29+
return max(0, $price);
3330
}
3431

3532
/**

app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ protected function setUp()
4949
'getCustomOption',
5050
])
5151
->getMockForAbstractClass();
52-
$this->saleableItem->expects($this->once())
53-
->method('getPriceInfo')
54-
->willReturn($this->priceInfoMock);
5552

5653
$this->calculator = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\CalculatorInterface::class)
5754
->getMockForAbstractClass();
@@ -109,11 +106,28 @@ public function testGetValue()
109106

110107
public function testGetValueWithNoCustomOption()
111108
{
109+
$priceValue = 100;
110+
111+
$priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
112+
->getMockForAbstractClass();
113+
$priceMock->expects($this->once())
114+
->method('getValue')
115+
->willReturn($priceValue);
116+
112117
$this->saleableItem->expects($this->once())
113118
->method('getCustomOption')
114119
->with('simple_product')
115120
->willReturn(null);
116121

117-
$this->assertEquals(0, $this->model->getValue());
122+
$this->saleableItem->expects($this->once())
123+
->method('getPriceInfo')
124+
->willReturn($this->priceInfoMock);
125+
126+
$this->priceInfoMock->expects($this->once())
127+
->method('getPrice')
128+
->with(ConfigurableProduct::PRICE_CODE)
129+
->willReturn($priceMock);
130+
131+
$this->assertEquals(100, $this->model->getValue());
118132
}
119133
}

0 commit comments

Comments
 (0)