Skip to content

Commit ce3efb6

Browse files
authored
Merge pull request #2109 from magento-tango/2.1.13-PR-0.5
Fixed issues: - MAGETWO-60246 [Backport] - [Github]Magento 2.1.1 Problem with change currency #6746 - for 2.1.x - MAGETWO-70329 [GITHUB] The rich snippets are giving a warning for the element price #7173 - MAGETWO-85781 Configurable product Final Price ignores Catalog Rule - MAGETWO-83204 "Hide from Product Page" option does not work for child of configurable product - MAGETWO-83094 Products Ordered Report exported CSV is empty - MAGETWO-71701 [Backport] - Catalog top nav, CSS class not set to active when using Varnish - for 2.1 - MAGETWO-71229 Warning message is cached and shown a few times on the shopping cart
2 parents 6164f8e + 8980fec commit ce3efb6

File tree

32 files changed

+1014
-310
lines changed

32 files changed

+1014
-310
lines changed

app/code/Magento/Backend/Model/Url.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -189,33 +189,30 @@ public function getUrl($routePath = null, $routeParams = null)
189189
}
190190

191191
$cacheSecretKey = false;
192-
if (is_array($routeParams) && isset($routeParams['_cache_secret_key'])) {
192+
if (isset($routeParams['_cache_secret_key'])) {
193193
unset($routeParams['_cache_secret_key']);
194194
$cacheSecretKey = true;
195195
}
196196
$result = parent::getUrl($routePath, $routeParams);
197197
if (!$this->useSecretKey()) {
198198
return $result;
199199
}
200+
200201
$this->_setRoutePath($routePath);
201202
$routeName = $this->_getRouteName('*');
202203
$controllerName = $this->_getControllerName(self::DEFAULT_CONTROLLER_NAME);
203204
$actionName = $this->_getActionName(self::DEFAULT_ACTION_NAME);
204-
if ($cacheSecretKey) {
205-
$secret = [self::SECRET_KEY_PARAM_NAME => "\${$routeName}/{$controllerName}/{$actionName}\$"];
206-
} else {
207-
$secret = [
208-
self::SECRET_KEY_PARAM_NAME => $this->getSecretKey($routeName, $controllerName, $actionName),
209-
];
210-
}
211-
if (is_array($routeParams)) {
212-
$routeParams = array_merge($secret, $routeParams);
213-
} else {
214-
$routeParams = $secret;
215-
}
216-
if (is_array($this->_getRouteParams())) {
217-
$routeParams = array_merge($this->_getRouteParams(), $routeParams);
205+
if (!isset($routeParams[self::SECRET_KEY_PARAM_NAME])) {
206+
if (!is_array($routeParams)) {
207+
$routeParams = [];
208+
}
209+
210+
$secretKey = $cacheSecretKey
211+
? "\${$routeName}/{$controllerName}/{$actionName}\$"
212+
: $this->getSecretKey($routeName, $controllerName, $actionName);
213+
$routeParams[self::SECRET_KEY_PARAM_NAME] = $secretKey;
218214
}
215+
219216
return parent::getUrl("{$routeName}/{$controllerName}/{$actionName}", $routeParams);
220217
}
221218

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,12 +1058,7 @@ protected function _afterLoad()
10581058
*/
10591059
public function cleanCache()
10601060
{
1061-
if ($this->getId()) {
1062-
$this->_cacheManager->clean(
1063-
self::CACHE_TAG . '_' . $this->getId()
1064-
);
1065-
}
1066-
return $this;
1061+
return $this->cleanModelCache();
10671062
}
10681063

10691064
/**

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,21 +1391,6 @@ public function testGetOptionByIdForProductWithoutOptions()
13911391
$this->assertNull($this->model->getOptionById(100));
13921392
}
13931393

1394-
public function testCleanCache()
1395-
{
1396-
//Without an ID cleanCache won't clean anything because the entity is
1397-
//not identified and it will be called later exactly once.
1398-
$this->model->setId(null);
1399-
$this->cacheManagerMock
1400-
->expects($this->once())
1401-
->method('clean');
1402-
$this->model->cleanCache();
1403-
1404-
//Now that ID is set clean will be called.
1405-
$this->model->setId(1);
1406-
$this->model->cleanCache();
1407-
}
1408-
14091394
public function testGetCacheTags()
14101395
{
14111396
//If entity is identified getCacheTags has to return the same values

app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
<?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
2020
data-price-amount="<?php /* @escapeNotVerified */ echo $block->getDisplayValue(); ?>"
2121
data-price-type="<?php /* @escapeNotVerified */ echo $block->getPriceType(); ?>"
22-
class="price-wrapper <?php /* @escapeNotVerified */ echo $block->getPriceWrapperCss(); ?>"
23-
<?php echo $block->getSchema() ? ' itemprop="price"' : '' ?>>
24-
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
22+
class="price-wrapper <?php /* @escapeNotVerified */ echo $block->getPriceWrapperCss(); ?>">
23+
<?php /* @noEscape */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
2524
</span>
25+
<?php if ($block->getSchema()): ?>
26+
<span class="_hidden" itemprop="price">
27+
<?php /* @noEscape */ echo $block->getDisplayValue() ?>
28+
</span>
29+
<?php endif; ?>
2630
<?php if ($block->hasAdjustmentsHtml()): ?>
2731
<?php echo $block->getAdjustmentsHtml() ?>
2832
<?php endif; ?>

app/code/Magento/Catalog/view/frontend/web/js/validate-product.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ define([
3131
* @param {Object} form
3232
* @returns {Boolean}
3333
*/
34-
submitHandler: function (form) {
34+
submitHandler: function (form, event) {
3535
var jqForm = $(form).catalogAddToCart({
3636
bindSubmit: bindSubmit
3737
});
3838

39-
jqForm.catalogAddToCart('submitForm', jqForm);
39+
jqForm.catalogAddToCart('submitForm', jqForm, event);
4040

4141
return false;
4242
}

app/code/Magento/CatalogRule/Model/Rule/Condition/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function validate(\Magento\Framework\Model\AbstractModel $model)
2424
{
2525
$attrCode = $this->getAttribute();
2626
if ('category_ids' == $attrCode) {
27-
return $this->validateAttribute($model->getAvailableInCategories());
27+
return parent::validate($model);
2828
}
2929

3030
$oldAttrValue = $model->getData($attrCode);

app/code/Magento/CatalogRule/Test/Unit/Model/Rule/Condition/ProductTest.php

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,51 +28,41 @@ class ProductTest extends \PHPUnit_Framework_TestCase
2828
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute|\PHPUnit_Framework_MockObject_MockObject */
2929
protected $eavAttributeResource;
3030

31+
/** @var \Magento\Catalog\Model\ResourceModel\Category|\PHPUnit_Framework_MockObject_MockObject */
32+
private $category;
33+
34+
/** @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */
35+
private $connection;
36+
37+
/** @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject */
38+
private $dbSelect;
39+
3140
protected function setUp()
3241
{
33-
$this->config = $this->getMock('Magento\Eav\Model\Config', ['getAttribute'], [], '', false);
34-
$this->productModel = $this->getMock(
35-
'Magento\Catalog\Model\Product',
36-
[
37-
'__wakeup',
38-
'getAvailableInCategories',
39-
'hasData',
40-
'getData',
41-
'getId',
42-
'getStoreId',
43-
'getResource',
44-
'addAttributeToSelect',
45-
],
46-
[],
47-
'',
48-
false
49-
);
50-
$this->productResource = $this->getMock(
51-
'Magento\Catalog\Model\ResourceModel\Product',
52-
['loadAllAttributes',
53-
'getAttributesByCode',
54-
'getAttribute'
55-
],
56-
[],
57-
'',
58-
false
59-
);
60-
$this->eavAttributeResource = $this->getMock(
61-
'\Magento\Catalog\Model\ResourceModel\Eav\Attribute',
62-
[
63-
'__wakeup',
64-
'isAllowedForRuleCondition',
65-
'getDataUsingMethod',
66-
'getAttributeCode',
67-
'getFrontendLabel',
68-
'isScopeGlobal',
69-
'getBackendType',
70-
'getFrontendInput'
71-
],
72-
[],
73-
'',
74-
false
75-
);
42+
$this->config = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
43+
->disableOriginalConstructor()
44+
->setMethods(['getAttribute'])
45+
->getMock();
46+
$this->productModel = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
47+
->disableOriginalConstructor()
48+
->getMock();
49+
$this->category = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category::class)
50+
->disableOriginalConstructor()
51+
->getMock();
52+
$this->productResource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product::class)
53+
->setMethods(['loadAllAttributes', 'getAttributesByCode', 'getAttribute', 'getConnection', 'getTable'])
54+
->disableOriginalConstructor()
55+
->getMock();
56+
$this->connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
57+
->disableOriginalConstructor()
58+
->getMockForAbstractClass();
59+
$this->dbSelect = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
60+
->disableOriginalConstructor()
61+
->setMethods(['from', 'where'])
62+
->getMock();
63+
$this->eavAttributeResource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
64+
->disableOriginalConstructor()
65+
->getMock();
7666

7767
$this->productResource->expects($this->any())->method('loadAllAttributes')
7868
->will($this->returnSelf());
@@ -89,11 +79,12 @@ protected function setUp()
8979

9080
$this->objectManagerHelper = new ObjectManagerHelper($this);
9181
$this->product = $this->objectManagerHelper->getObject(
92-
'Magento\CatalogRule\Model\Rule\Condition\Product',
82+
\Magento\CatalogRule\Model\Rule\Condition\Product::class,
9383
[
9484
'config' => $this->config,
9585
'product' => $this->productModel,
96-
'productResource' => $this->productResource
86+
'productResource' => $this->productResource,
87+
'category' => $this->category
9788
]
9889
);
9990
}
@@ -103,12 +94,27 @@ protected function setUp()
10394
*/
10495
public function testValidateMeetsCategory()
10596
{
97+
$categoryIdList = [1, 2, 3];
98+
99+
$this->productResource->expects($this->atLeastOnce())
100+
->method('getConnection')
101+
->willReturn($this->connection);
102+
$this->connection->expects($this->atLeastOnce())
103+
->method('select')
104+
->willReturn($this->dbSelect);
105+
$this->dbSelect->expects($this->atLeastOnce())
106+
->method('from')
107+
->willReturnSelf();
108+
$this->dbSelect->expects($this->atLeastOnce())
109+
->method('where')
110+
->willReturnSelf();
111+
$this->connection->expects($this->once())
112+
->method('fetchCol')
113+
->willReturn($categoryIdList);
106114
$this->product->setData('attribute', 'category_ids');
107115
$this->product->setData('value_parsed', '1');
108-
$this->product->setData('operator', '>=');
116+
$this->product->setData('operator', '{}');
109117

110-
$this->productModel->expects($this->once())->method('getAvailableInCategories')
111-
->will($this->returnValue('2'));
112118
$this->assertTrue($this->product->validate($this->productModel));
113119
}
114120

app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ public function getCurrencyRate()
156156
{
157157
$rate = $this->_getData('currency_rate');
158158
if ($rate === null) {
159-
$rate = $this->_storeManager->getStore($this->getStoreId())
160-
->getCurrentCurrencyRate();
159+
$rate = $this->_storeManager->getStore()->getCurrentCurrencyRate();
161160
}
162161
if (!$rate) {
163162
$rate = 1;
@@ -175,6 +174,11 @@ public function getCurrencyRate()
175174
*/
176175
protected function _renderRangeLabel($fromPrice, $toPrice)
177176
{
177+
$fromPrice *= $this->getCurrencyRate();
178+
if ($toPrice) {
179+
$toPrice *= $this->getCurrencyRate();
180+
}
181+
178182
$formattedFromPrice = $this->priceCurrency->format($fromPrice);
179183
if ($toPrice === '') {
180184
return __('%1 and above', $formattedFromPrice);
@@ -212,7 +216,7 @@ protected function _getItemsData()
212216
if (strpos($key, '_') === false) {
213217
continue;
214218
}
215-
$data[] = $this->prepareData($key, $count, $data);
219+
$data[] = $this->prepareData($key, $count);
216220
}
217221
}
218222

@@ -262,8 +266,8 @@ private function prepareData($key, $count)
262266
$to = $this->getTo($to);
263267
}
264268
$label = $this->_renderRangeLabel(
265-
empty($from) ? 0 : $from * $this->getCurrencyRate(),
266-
empty($to) ? $to : $to * $this->getCurrencyRate()
269+
empty($from) ? 0 : $from,
270+
$to
267271
);
268272
$value = $from . '-' . $to . $this->dataProvider->getAdditionalRequestData();
269273

0 commit comments

Comments
 (0)