Skip to content

Commit 28730e7

Browse files
author
Olexandr Lysenko
committed
Merge remote-tracking branch 'mainline/2.1' into MAGETWO-54677-patch21
2 parents b794302 + d530867 commit 28730e7

File tree

39 files changed

+1626
-247
lines changed

39 files changed

+1626
-247
lines changed

app/code/Magento/Catalog/Block/Product/ListProduct.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ public function getProductPrice(\Magento\Catalog\Model\Product $product)
363363
[
364364
'include_container' => true,
365365
'display_minimal_price' => true,
366-
'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST
366+
'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
367+
'list_category_page' => true
367368
]
368369
);
369370
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,6 +1875,9 @@ protected function _productLimitationPrice($joinLeft = false)
18751875
return $this;
18761876
}
18771877

1878+
// Preventing overriding price loaded from EAV because we want to use the one from index
1879+
$this->removeAttributeToSelect('price');
1880+
18781881
$connection = $this->getConnection();
18791882
$select = $this->getSelect();
18801883
$joinCond = join(

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,26 @@ public function showMinimalPrice()
118118
&& $minimalPriceAValue
119119
&& $minimalPriceAValue < $finalPriceValue;
120120
}
121+
122+
/**
123+
* Get Key for caching block content
124+
*
125+
* @return string
126+
*/
127+
public function getCacheKey()
128+
{
129+
return parent::getCacheKey() . ($this->getData('list_category_page') ? '-list-category-page': '');
130+
}
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+
}
121143
}

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

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,25 @@ protected function setUp()
8484
$cacheState = $this->getMockBuilder(\Magento\Framework\App\Cache\StateInterface::class)
8585
->getMockForAbstractClass();
8686

87+
$appState = $this->getMockBuilder(\Magento\Framework\App\State::class)
88+
->disableOriginalConstructor()
89+
->getMock();
90+
91+
$resolver = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Resolver::class)
92+
->disableOriginalConstructor()
93+
->getMock();
94+
95+
$urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
96+
->getMockForAbstractClass();
97+
98+
$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
99+
->getMockForAbstractClass();
100+
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));
105+
87106
$scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface');
88107
$context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false);
89108
$context->expects($this->any())
@@ -104,6 +123,18 @@ protected function setUp()
104123
$context->expects($this->any())
105124
->method('getCacheState')
106125
->will($this->returnValue($cacheState));
126+
$context->expects($this->any())
127+
->method('getStoreManager')
128+
->will($this->returnValue($storeManager));
129+
$context->expects($this->any())
130+
->method('getAppState')
131+
->will($this->returnValue($appState));
132+
$context->expects($this->any())
133+
->method('getResolver')
134+
->will($this->returnValue($resolver));
135+
$context->expects($this->any())
136+
->method('getUrlBuilder')
137+
->will($this->returnValue($urlBuilder));
107138

108139
$this->rendererPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool')
109140
->disableOriginalConstructor()
@@ -122,7 +153,7 @@ protected function setUp()
122153
'saleableItem' => $this->product,
123154
'rendererPool' => $this->rendererPool,
124155
'price' => $this->price,
125-
'data' => ['zone' => 'test_zone']
156+
'data' => ['zone' => 'test_zone', 'list_category_page' => true]
126157
]
127158
);
128159
}
@@ -219,6 +250,7 @@ public function testRenderAmountMinimal()
219250

220251
$arguments = [
221252
'zone' => 'test_zone',
253+
'list_category_page' => true,
222254
'display_label' => 'As low as',
223255
'price_id' => $priceId,
224256
'include_container' => false,
@@ -338,4 +370,15 @@ public function testHidePrice()
338370

339371
$this->assertEmpty($this->object->toHtml());
340372
}
373+
374+
public function testGetCacheKey()
375+
{
376+
$result = $this->object->getCacheKey();
377+
$this->assertStringEndsWith('list-category-page', $result);
378+
}
379+
380+
public function testGetCacheKeyInfo()
381+
{
382+
$this->assertArrayHasKey('display_minimal_price', $this->object->getCacheKeyInfo());
383+
}
341384
}

app/code/Magento/Cms/Setup/UpgradeData.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,11 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
235235
</div>
236236
EOD;
237237
$privacyAndCookiePolicyPage = $this->createPage()->load(self::PRIVACY_COOKIE_PAGE_ID);
238-
$privacyAndCookiePolicyPage->setContent($newPageContent);
239-
$privacyAndCookiePolicyPage->save();
238+
$privacyAndCookiePolicyPageId = $privacyAndCookiePolicyPage->getId();
239+
if ($privacyAndCookiePolicyPageId) {
240+
$privacyAndCookiePolicyPage->setContent($newPageContent);
241+
$privacyAndCookiePolicyPage->save();
242+
}
240243
}
241244
$setup->endSetup();
242245
}

0 commit comments

Comments
 (0)