Skip to content

Commit b55821e

Browse files
author
Sergey Semenov
committed
MAGETWO-51993: Product Price isn't displayed in "My Wish List" customer's account widget if another browser is used
1 parent c2bd1e4 commit b55821e

File tree

3 files changed

+130
-7
lines changed

3 files changed

+130
-7
lines changed

app/code/Magento/Wishlist/Block/Customer/Sidebar.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,36 @@ public function getProductPriceHtml(
4343
$arguments['zone'] = $renderZone;
4444
}
4545

46+
$price = '';
47+
48+
$priceRender = $this->getPriceRender();
49+
if ($priceRender) {
50+
$price = $priceRender->render($priceType, $product, $arguments);
51+
}
52+
53+
return $price;
54+
}
55+
56+
/**
57+
* Get price render block
58+
*
59+
* @return Render
60+
*/
61+
private function getPriceRender()
62+
{
4663
/** @var Render $priceRender */
4764
$priceRender = $this->getLayout()->getBlock('product.price.render.default');
4865
if (!$priceRender) {
4966
$priceRender = $this->getLayout()->createBlock(
5067
'Magento\Framework\Pricing\Render',
5168
'product.price.render.default',
52-
['data' => ['price_render_handle' => 'catalog_product_prices']]
69+
[
70+
'data' => [
71+
'price_render_handle' => 'catalog_product_prices',
72+
],
73+
]
5374
);
5475
}
55-
56-
$price = '';
57-
if ($priceRender) {
58-
$price = $priceRender->render($priceType, $product, $arguments);
59-
}
60-
return $price;
76+
return $priceRender;
6177
}
6278
}

app/code/Magento/Wishlist/Pricing/Render/ConfiguredPriceBox.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Wishlist\Pricing\Render;
77

8+
use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
9+
810
class ConfiguredPriceBox extends \Magento\Catalog\Pricing\Render\ConfiguredPriceBox
911
{
1012
/**
@@ -14,4 +16,21 @@ protected function getCacheLifetime()
1416
{
1517
return null;
1618
}
19+
20+
/**
21+
* @inheritdoc
22+
*/
23+
protected function _prepareLayout()
24+
{
25+
/** @var $price \Magento\Catalog\Pricing\Price\ConfiguredPrice */
26+
$price = $this->getPrice();
27+
28+
/** @var $renderBlock \Magento\Catalog\Pricing\Render */
29+
$renderBlock = $this->getRenderBlock();
30+
if (!$renderBlock && $this->getItem() instanceof ItemInterface) {
31+
$price->setItem($this->getItem());
32+
}
33+
34+
return parent::_prepareLayout();
35+
}
1736
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Wishlist\Test\Unit\Pricing\Render;
7+
8+
use Magento\Wishlist\Pricing\Render\ConfiguredPriceBox;
9+
10+
class ConfiguredPriceBoxTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject
14+
*/
15+
private $templateContext;
16+
17+
/**
18+
* @var \Magento\Framework\Pricing\SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
19+
*/
20+
private $saleableItem;
21+
22+
/**
23+
* @var \Magento\Framework\Pricing\Price\PriceInterface|\PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
private $price;
26+
27+
/**
28+
* @var \Magento\Framework\Pricing\Render\RendererPool|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
private $rendererPool;
31+
32+
/**
33+
* @var ConfiguredPriceBox
34+
*/
35+
private $model;
36+
37+
/**
38+
* @var \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
private $item;
41+
42+
protected function setUp()
43+
{
44+
$this->templateContext = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context')
45+
->disableOriginalConstructor()
46+
->getMock();
47+
48+
$this->saleableItem = $this->getMockBuilder('Magento\Framework\Pricing\SaleableInterface')
49+
->getMockForAbstractClass();
50+
51+
$this->price = $this->getMockBuilder('Magento\Framework\Pricing\Price\PriceInterface')
52+
->setMethods([
53+
'setItem',
54+
])
55+
->getMockForAbstractClass();
56+
57+
$this->rendererPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool')
58+
->disableOriginalConstructor()
59+
->getMock();
60+
61+
$this->item = $this->getMockBuilder('Magento\Catalog\Model\Product\Configuration\Item\ItemInterface')
62+
->getMockForAbstractClass();
63+
64+
$this->model = new ConfiguredPriceBox(
65+
$this->templateContext,
66+
$this->saleableItem,
67+
$this->price,
68+
$this->rendererPool,
69+
['item' => $this->item]
70+
);
71+
}
72+
73+
public function testSetLayout()
74+
{
75+
$layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface')
76+
->getMockForAbstractClass();
77+
78+
$this->price->expects($this->once())
79+
->method('setItem')
80+
->with($this->item)
81+
->willReturnSelf();
82+
83+
$this->assertInstanceOf(
84+
'Magento\Wishlist\Pricing\Render\ConfiguredPriceBox',
85+
$this->model->setLayout($layoutMock)
86+
);
87+
}
88+
}

0 commit comments

Comments
 (0)