Skip to content

Commit 81cb04c

Browse files
committed
Merge branch 'develop' into FearlessKiwis-MAGETWO-53130-Category-shows-old-price-on-price-index-scheduled
Conflicts: app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php
2 parents b346621 + e7e4a88 commit 81cb04c

File tree

27 files changed

+585
-373
lines changed

27 files changed

+585
-373
lines changed

ISSUE_TEMPLATE.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
Steps to reproduce
2-
--
3-
1. Install Magento from `develop` branch.
4-
2. [Example] Add Configurable Product to the cart.
5-
3. ...
1+
<!--- Provide a general summary of the issue in the Title above -->
2+
<!--- Before adding new issues, please, check this article https://github.com/magento/magento2/wiki/Issue-reporting-guidelines-->
63

7-
Expected result
8-
--
9-
1. [Example] Configurable product added to the shopping cart.
10-
2. ...
4+
### Preconditions
5+
<!--- Provide a more detailed information of environment you use -->
6+
<!--- Magento version, tag, HEAD, etc., PHP & MySQL version, etc.. -->
7+
1.
8+
2.
119

12-
Actual result
13-
--
14-
1. [Example] Error message appears: "Cannot save quote".
15-
2. [Screenshot, logs]
16-
3. ...
10+
### Steps to reproduce
11+
<!--- Provide a set of unambiguous steps to reproduce this bug include code, if relevant -->
12+
1.
13+
2.
14+
3.
15+
16+
### Expected result
17+
<!--- Tell us what should happen -->
18+
1.
19+
20+
### Actual result
21+
<!--- Tell us what happens instead -->
22+
1. [Screenshot, logs]
23+
24+
<!--- (This may be platform independent comment) -->

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Backend\Block\Media\Uploader;
1717
use Magento\Framework\View\Element\AbstractBlock;
1818
use Magento\Framework\App\Filesystem\DirectoryList;
19+
use Magento\Framework\Exception\FileSystemException;
1920

2021
class Content extends \Magento\Backend\Block\Widget
2122
{
@@ -34,6 +35,16 @@ class Content extends \Magento\Backend\Block\Widget
3435
*/
3536
protected $_jsonEncoder;
3637

38+
/**
39+
* @var \Magento\Catalog\Helper\Image
40+
*/
41+
private $imageHelper;
42+
43+
/**
44+
* @var \Magento\Framework\View\Asset\Repository
45+
*/
46+
private $assetRepo;
47+
3748
/**
3849
* @param \Magento\Backend\Block\Template\Context $context
3950
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
@@ -128,12 +139,22 @@ public function getImagesJson()
128139
is_array($value['images']) &&
129140
count($value['images'])
130141
) {
131-
$directory = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA);
142+
$mediaDir = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA);
132143
$images = $this->sortImagesByPosition($value['images']);
133144
foreach ($images as &$image) {
134145
$image['url'] = $this->_mediaConfig->getMediaUrl($image['file']);
135-
$fileHandler = $directory->stat($this->_mediaConfig->getMediaPath($image['file']));
136-
$image['size'] = $fileHandler['size'];
146+
try {
147+
$fileHandler = $mediaDir->stat($this->_mediaConfig->getMediaPath($image['file']));
148+
$image['size'] = $fileHandler['size'];
149+
} catch (FileSystemException $e) {
150+
$staticDir = $this->_filesystem->getDirectoryRead(DirectoryList::STATIC_VIEW);
151+
$image['url'] = $this->getImageHelper()->getDefaultPlaceholderUrl('thumbnail');
152+
$fileHandler = $staticDir->stat(
153+
$this->getAssetRepo()->createAsset($this->getImageHelper()->getPlaceholder('thumbnail'))->getPath()
154+
);
155+
$image['size'] = $fileHandler['size'];
156+
$this->_logger->warning($e);
157+
}
137158
}
138159
return $this->_jsonEncoder->encode($images);
139160
}
@@ -227,4 +248,31 @@ public function getImageTypesJson()
227248
{
228249
return $this->_jsonEncoder->encode($this->getImageTypes());
229250
}
251+
252+
/**
253+
* @return \Magento\Catalog\Helper\Image
254+
* @deprecated
255+
*/
256+
private function getImageHelper()
257+
{
258+
if ($this->imageHelper === null) {
259+
$this->imageHelper = \Magento\Framework\App\ObjectManager::getInstance()
260+
->get('Magento\Catalog\Helper\Image');
261+
}
262+
return $this->imageHelper;
263+
}
264+
265+
/**
266+
* @return \Magento\Framework\View\Asset\Repository
267+
* @deprecated
268+
*/
269+
private function getAssetRepo()
270+
{
271+
if ($this->assetRepo === null) {
272+
$this->assetRepo = \Magento\Framework\App\ObjectManager::getInstance()
273+
->get('\Magento\Framework\View\Asset\Repository');
274+
}
275+
276+
return $this->assetRepo;
277+
}
230278
}

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,16 @@ public function getCacheKey()
128128
{
129129
return parent::getCacheKey() . ($this->getData('list_category_page') ? '-list-category-page': '');
130130
}
131+
132+
/**
133+
* {@inheritdoc}
134+
*
135+
* @return array
136+
*/
137+
public function getCacheKeyInfo()
138+
{
139+
$cacheKeys = parent::getCacheKeyInfo();
140+
$cacheKeys['display_minimal_price'] = $this->getDisplayMinimalPrice();
141+
return $cacheKeys;
142+
}
131143
}

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php

Lines changed: 113 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\Filesystem;
99
use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content;
10+
use Magento\Framework\Phrase;
1011

1112
class ContentTest extends \PHPUnit_Framework_TestCase
1213
{
@@ -40,14 +41,30 @@ class ContentTest extends \PHPUnit_Framework_TestCase
4041
*/
4142
protected $galleryMock;
4243

44+
/**
45+
* @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject
46+
*/
47+
protected $imageHelper;
48+
49+
/**
50+
* @var \Magento\Framework\View\Asset\Repository|\PHPUnit_Framework_MockObject_MockObject
51+
*/
52+
protected $assetRepo;
53+
4354
/**
4455
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
4556
*/
4657
protected $objectManager;
4758

4859
public function setUp()
4960
{
50-
$this->fileSystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
61+
$this->fileSystemMock = $this->getMock(
62+
'Magento\Framework\Filesystem',
63+
['stat', 'getDirectoryRead'],
64+
[],
65+
'',
66+
false
67+
);
5168
$this->readMock = $this->getMock('Magento\Framework\Filesystem\Directory\ReadInterface');
5269
$this->galleryMock = $this->getMock(
5370
'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery',
@@ -56,7 +73,13 @@ public function setUp()
5673
'',
5774
false
5875
);
59-
$this->mediaConfigMock = $this->getMock('Magento\Catalog\Model\Product\Media\Config', [], [], '', false);
76+
$this->mediaConfigMock = $this->getMock(
77+
'Magento\Catalog\Model\Product\Media\Config',
78+
['getMediaUrl', 'getMediaPath'],
79+
[],
80+
'',
81+
false
82+
);
6083
$this->jsonEncoderMock = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface')
6184
->disableOriginalConstructor()
6285
->getMock();
@@ -130,7 +153,6 @@ public function testGetImagesJson()
130153

131154
$this->mediaConfigMock->expects($this->any())->method('getMediaUrl')->willReturnMap($url);
132155
$this->mediaConfigMock->expects($this->any())->method('getMediaPath')->willReturnMap($mediaPath);
133-
134156
$this->readMock->expects($this->any())->method('stat')->willReturnMap($sizeMap);
135157
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');
136158

@@ -144,4 +166,92 @@ public function testGetImagesJsonWithoutImages()
144166

145167
$this->assertSame('[]', $this->content->getImagesJson());
146168
}
169+
170+
public function testGetImagesJsonWithException()
171+
{
172+
$this->imageHelper = $this->getMockBuilder('Magento\Catalog\Helper\Image')
173+
->disableOriginalConstructor()
174+
->setMethods(['getDefaultPlaceholderUrl', 'getPlaceholder'])
175+
->getMock();
176+
177+
$this->assetRepo = $this->getMockBuilder('Magento\Framework\View\Asset\Repository')
178+
->disableOriginalConstructor()
179+
->setMethods(['createAsset', 'getPath'])
180+
->getMock();
181+
182+
$this->objectManager->setBackwardCompatibleProperty(
183+
$this->content,
184+
'imageHelper',
185+
$this->imageHelper
186+
);
187+
188+
$this->objectManager->setBackwardCompatibleProperty(
189+
$this->content,
190+
'assetRepo',
191+
$this->assetRepo
192+
);
193+
194+
$placeholderUrl = 'url_to_the_placeholder/placeholder.jpg';
195+
196+
$sizePlaceholder = ['size' => 399659];
197+
198+
$imagesResult = [
199+
[
200+
'value_id' => '2',
201+
'file' => 'file_2.jpg',
202+
'media_type' => 'image',
203+
'position' => '0',
204+
'url' => 'url_to_the_placeholder/placeholder.jpg',
205+
'size' => 399659
206+
],
207+
[
208+
'value_id' => '1',
209+
'file' => 'file_1.jpg',
210+
'media_type' => 'image',
211+
'position' => '1',
212+
'url' => 'url_to_the_placeholder/placeholder.jpg',
213+
'size' => 399659
214+
]
215+
];
216+
217+
$images = [
218+
'images' => [
219+
[
220+
'value_id' => '1',
221+
'file' => 'file_1.jpg',
222+
'media_type' => 'image',
223+
'position' => '1'
224+
],
225+
[
226+
'value_id' => '2',
227+
'file' => 'file_2.jpg',
228+
'media_type' => 'image',
229+
'position' => '0'
230+
]
231+
]
232+
];
233+
234+
$this->content->setElement($this->galleryMock);
235+
$this->galleryMock->expects($this->once())->method('getImages')->willReturn($images);
236+
$this->fileSystemMock->expects($this->any())->method('getDirectoryRead')->willReturn($this->readMock);
237+
$this->mediaConfigMock->expects($this->any())->method('getMediaUrl');
238+
$this->mediaConfigMock->expects($this->any())->method('getMediaPath');
239+
$this->readMock->expects($this->any())->method('stat')->willReturnOnConsecutiveCalls(
240+
$this->throwException(
241+
new \Magento\Framework\Exception\FileSystemException(new \Magento\Framework\Phrase('test'))
242+
),
243+
$sizePlaceholder,
244+
$this->throwException(
245+
new \Magento\Framework\Exception\FileSystemException(new \Magento\Framework\Phrase('test'))
246+
),
247+
$sizePlaceholder
248+
);
249+
$this->imageHelper->expects($this->any())->method('getDefaultPlaceholderUrl')->willReturn($placeholderUrl);
250+
$this->imageHelper->expects($this->any())->method('getPlaceholder');
251+
$this->assetRepo->expects($this->any())->method('createAsset')->willReturnSelf();
252+
$this->assetRepo->expects($this->any())->method('getPath');
253+
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');
254+
255+
$this->assertSame(json_encode($imagesResult), $this->content->getImagesJson());
256+
}
147257
}

app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,14 @@ protected function setUp()
9494

9595
$urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
9696
->getMockForAbstractClass();
97-
98-
$storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
99-
->getMockForAbstractClass();
100-
97+
10198
$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
10299
->getMockForAbstractClass();
103100

104-
$storeManager->expects($this->any())
105-
->method('getStore')
106-
->will($this->returnValue($store));
101+
$storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface')
102+
->setMethods(['getStore', 'getCode'])
103+
->getMockForAbstractClass();
104+
$storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
107105

108106
$scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface');
109107
$context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false);
@@ -137,7 +135,7 @@ protected function setUp()
137135
$context->expects($this->any())
138136
->method('getUrlBuilder')
139137
->will($this->returnValue($urlBuilder));
140-
138+
141139
$this->rendererPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool')
142140
->disableOriginalConstructor()
143141
->getMock();
@@ -378,4 +376,9 @@ public function testGetCacheKey()
378376
$result = $this->object->getCacheKey();
379377
$this->assertStringEndsWith('list-category-page', $result);
380378
}
379+
380+
public function testGetCacheKeyInfo()
381+
{
382+
$this->assertArrayHasKey('display_minimal_price', $this->object->getCacheKeyInfo());
383+
}
381384
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ protected function getTierPriceStructure($tierPricePath)
412412
'data' => [
413413
'config' => [
414414
'componentType' => 'dynamicRows',
415-
'label' => __('Tier Price'),
415+
'label' => __('Customer Group Price'),
416416
'renderDefaultRecord' => false,
417417
'recordTemplate' => 'record',
418418
'dataScope' => '',

app/code/Magento/Catalog/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ Images,Images
405405
Select...,Select...
406406
"Advanced Pricing","Advanced Pricing"
407407
"Tier Price","Tier Price"
408+
"Customer Group Price","Customer Group Price"
408409
"Customer Group","Customer Group"
409410
"Special Price From","Special Price From"
410411
To,To

app/code/Magento/PageCache/etc/varnish3.vcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import std;
66
backend default {
77
.host = "/* {{ host }} */";
88
.port = "/* {{ port }} */";
9+
.first_byte_timeout = 600s;
910
}
1011

1112
acl purge {

app/code/Magento/PageCache/etc/varnish4.vcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import std;
77
backend default {
88
.host = "/* {{ host }} */";
99
.port = "/* {{ port }} */";
10+
.first_byte_timeout = 600s;
1011
}
1112

1213
acl purge {

0 commit comments

Comments
 (0)