Skip to content

Commit b0a4c49

Browse files
committed
Merge remote-tracking branch 'magento2/2.2-develop' into MAGETWO-88411
2 parents d952830 + 32892a4 commit b0a4c49

File tree

109 files changed

+1094
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1094
-363
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
define([
88
'jquery',
99
'underscore',
10+
'mage/utils/wrapper',
1011
'Magento_Checkout/js/view/payment/default',
1112
'Magento_Braintree/js/view/payment/adapter',
1213
'Magento_Checkout/js/model/quote',
@@ -18,6 +19,7 @@ define([
1819
], function (
1920
$,
2021
_,
22+
wrapper,
2123
Component,
2224
Braintree,
2325
quote,
@@ -218,8 +220,9 @@ define([
218220

219221
/**
220222
* Re-init PayPal Auth Flow
223+
* @param {Function} callback - Optional callback
221224
*/
222-
reInitPayPal: function () {
225+
reInitPayPal: function (callback) {
223226
if (Braintree.checkout) {
224227
Braintree.checkout.teardown(function () {
225228
Braintree.checkout = null;
@@ -228,6 +231,18 @@ define([
228231

229232
this.disableButton();
230233
this.clientConfig.paypal.amount = this.grandTotalAmount;
234+
this.clientConfig.paypal.shippingAddressOverride = this.getShippingAddress();
235+
236+
if (callback) {
237+
this.clientConfig.onReady = wrapper.wrap(
238+
this.clientConfig.onReady,
239+
function (original, checkout) {
240+
this.clientConfig.onReady = original;
241+
original(checkout);
242+
callback();
243+
}.bind(this)
244+
);
245+
}
231246

232247
Braintree.setConfig(this.clientConfig);
233248
Braintree.setup();
@@ -404,15 +419,19 @@ define([
404419
* Triggers when customer click "Continue to PayPal" button
405420
*/
406421
payWithPayPal: function () {
407-
if (additionalValidators.validate()) {
422+
this.reInitPayPal(function () {
423+
if (!additionalValidators.validate()) {
424+
return;
425+
}
426+
408427
try {
409428
Braintree.checkout.paypal.initAuthFlow();
410429
} catch (e) {
411430
this.messageContainer.addErrorMessage({
412431
message: $t('Payment ' + this.getTitle() + ' can\'t be initialized.')
413432
});
414433
}
415-
}
434+
}.bind(this));
416435
},
417436

418437
/**

app/code/Magento/Catalog/Console/Command/ImagesResizeCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private function getViewImages(array $themes): array
216216
]);
217217
$images = $config->getMediaEntities('Magento_Catalog', ImageHelper::MEDIA_TYPE_CONFIG_NODE);
218218
foreach ($images as $imageId => $imageData) {
219-
$uniqIndex = $this->getUniqImageIndex($imageData);
219+
$uniqIndex = $this->getUniqueImageIndex($imageData);
220220
$imageData['id'] = $imageId;
221221
$viewImages[$uniqIndex] = $imageData;
222222
}
@@ -225,11 +225,11 @@ private function getViewImages(array $themes): array
225225
}
226226

227227
/**
228-
* Get uniq image index
228+
* Get unique image index
229229
* @param array $imageData
230230
* @return string
231231
*/
232-
private function getUniqImageIndex(array $imageData): string
232+
private function getUniqueImageIndex(array $imageData): string
233233
{
234234
ksort($imageData);
235235
unset($imageData['type']);

app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public function getOptionPrice($optionValue, $basePrice)
338338
{
339339
$option = $this->getOption();
340340

341-
return $this->_getChargableOptionPrice($option->getPrice(), $option->getPriceType() == 'percent', $basePrice);
341+
return $this->_getChargeableOptionPrice($option->getPrice(), $option->getPriceType() == 'percent', $basePrice);
342342
}
343343

344344
/**
@@ -392,14 +392,27 @@ public function getProductOptions()
392392
}
393393

394394
/**
395-
* Return final chargable price for option
396-
*
397395
* @param float $price Price of option
398396
* @param boolean $isPercent Price type - percent or fixed
399397
* @param float $basePrice For percent price type
400398
* @return float
399+
* @deprecated 102.0.4 typo in method name
400+
* @see _getChargeableOptionPrice
401401
*/
402402
protected function _getChargableOptionPrice($price, $isPercent, $basePrice)
403+
{
404+
return $this->_getChargeableOptionPrice($price, $isPercent, $basePrice);
405+
}
406+
407+
/**
408+
* Return final chargeable price for option
409+
*
410+
* @param float $price Price of option
411+
* @param boolean $isPercent Price type - percent or fixed
412+
* @param float $basePrice For percent price type
413+
* @return float
414+
*/
415+
protected function _getChargeableOptionPrice($price, $isPercent, $basePrice)
403416
{
404417
if ($isPercent) {
405418
return $basePrice * $price / 100;

app/code/Magento/Catalog/Model/Product/Option/Type/Select.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function getOptionPrice($optionValue, $basePrice)
222222
foreach (explode(',', $optionValue) as $value) {
223223
$_result = $option->getValueById($value);
224224
if ($_result) {
225-
$result += $this->_getChargableOptionPrice(
225+
$result += $this->_getChargeableOptionPrice(
226226
$_result->getPrice(),
227227
$_result->getPriceType() == 'percent',
228228
$basePrice
@@ -237,7 +237,7 @@ public function getOptionPrice($optionValue, $basePrice)
237237
} elseif ($this->_isSingleSelection()) {
238238
$_result = $option->getValueById($optionValue);
239239
if ($_result) {
240-
$result = $this->_getChargableOptionPrice(
240+
$result = $this->_getChargeableOptionPrice(
241241
$_result->getPrice(),
242242
$_result->getPriceType() == 'percent',
243243
$basePrice

app/code/Magento/Catalog/Plugin/Block/Topmenu.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ private function getCategoryAsArray($category, $currentCategory, $isParentActive
162162
'url' => $this->catalogCategory->getCategoryUrl($category),
163163
'has_active' => in_array((string)$category->getId(), explode('/', $currentCategory->getPath()), true),
164164
'is_active' => $category->getId() == $currentCategory->getId(),
165+
'is_category' => true,
165166
'is_parent_active' => $isParentActive
166167
];
167168
}

app/code/Magento/Catalog/Setup/InstallSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
674674
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
675675
null,
676676
['unsigned' => true, 'nullable' => false, 'default' => '0'],
677-
'Attriute Set ID'
677+
'Attribute Set ID'
678678
)
679679
->addColumn(
680680
'parent_id',

app/code/Magento/Catalog/view/base/web/js/price-options.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ define([
2020
optionConfig: {},
2121
optionHandlers: {},
2222
optionTemplate: '<%= data.label %>' +
23-
'<% if (data.finalPrice.value) { %>' +
23+
'<% if (data.finalPrice.value > 0) { %>' +
2424
' +<%- data.finalPrice.formatted %>' +
25+
'<% } else if (data.finalPrice.value < 0) { %>' +
26+
' <%- data.finalPrice.formatted %>' +
2527
'<% } %>',
2628
controlContainer: 'dd'
2729
};

app/code/Magento/Catalog/view/frontend/web/js/product/breadcrumbs.js

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,10 @@ define([
1616
categoryUrlSuffix: '',
1717
useCategoryPathInUrl: false,
1818
product: '',
19+
categoryItemSelector: '.category-item',
1920
menuContainer: '[data-action="navigation"] > ul'
2021
},
2122

22-
/** @inheritdoc */
23-
_init: function () {
24-
var menu;
25-
26-
// render breadcrumbs after navigation menu is loaded.
27-
menu = $(this.options.menuContainer).data('mageMenu');
28-
29-
if (typeof menu === 'undefined') {
30-
this._on($(this.options.menuContainer), {
31-
'menucreate': this._super
32-
});
33-
} else {
34-
this._super();
35-
}
36-
},
37-
3823
/** @inheritdoc */
3924
_render: function () {
4025
this._appendCatalogCrumbs();
@@ -87,18 +72,10 @@ define([
8772
* @private
8873
*/
8974
_getCategoryCrumb: function (menuItem) {
90-
var categoryId,
91-
categoryName,
92-
categoryUrl;
93-
94-
categoryId = /(\d+)/i.exec(menuItem.attr('id'))[0];
95-
categoryName = menuItem.text();
96-
categoryUrl = menuItem.attr('href');
97-
9875
return {
99-
'name': 'category' + categoryId,
100-
'label': categoryName,
101-
'link': categoryUrl,
76+
'name': 'category',
77+
'label': menuItem.text(),
78+
'link': menuItem.attr('href'),
10279
'title': ''
10380
};
10481
},
@@ -166,7 +143,10 @@ define([
166143
categoryMenuItem = null;
167144

168145
if (categoryUrl && menu.length) {
169-
categoryMenuItem = menu.find('a[href="' + categoryUrl + '"]');
146+
categoryMenuItem = menu.find(
147+
this.options.categoryItemSelector +
148+
' > a[href="' + categoryUrl + '"]'
149+
);
170150
}
171151

172152
return categoryMenuItem;

app/code/Magento/Customer/Model/Customer/NotificationStorage.php

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Customer\Model\Customer;
77

8+
use Magento\Framework\App\ObjectManager;
89
use Magento\Framework\Cache\FrontendInterface;
910
use Magento\Framework\Serialize\SerializerInterface;
1011

@@ -18,21 +19,21 @@ class NotificationStorage
1819
private $cache;
1920

2021
/**
21-
* @param FrontendInterface $cache
22-
*/
23-
24-
/**
25-
* @param FrontendInterface $cache
22+
* @var SerializerInterface
2623
*/
2724
private $serializer;
2825

2926
/**
3027
* NotificationStorage constructor.
3128
* @param FrontendInterface $cache
29+
* @param SerializerInterface $serializer
3230
*/
33-
public function __construct(FrontendInterface $cache)
34-
{
31+
public function __construct(
32+
FrontendInterface $cache,
33+
SerializerInterface $serializer = null
34+
) {
3535
$this->cache = $cache;
36+
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
3637
}
3738

3839
/**
@@ -45,7 +46,7 @@ public function __construct(FrontendInterface $cache)
4546
public function add($notificationType, $customerId)
4647
{
4748
$this->cache->save(
48-
$this->getSerializer()->serialize([
49+
$this->serializer->serialize([
4950
'customer_id' => $customerId,
5051
'notification_type' => $notificationType
5152
]),
@@ -88,19 +89,4 @@ private function getCacheKey($notificationType, $customerId)
8889
{
8990
return 'notification_' . $notificationType . '_' . $customerId;
9091
}
91-
92-
/**
93-
* Get serializer
94-
*
95-
* @return SerializerInterface
96-
* @deprecated 100.2.0
97-
*/
98-
private function getSerializer()
99-
{
100-
if ($this->serializer === null) {
101-
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()
102-
->get(SerializerInterface::class);
103-
}
104-
return $this->serializer;
105-
}
10692
}

app/code/Magento/Customer/Model/Visitor.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
namespace Magento\Customer\Model;
88

9-
use Magento\Framework\Indexer\StateInterface;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\App\RequestSafetyInterface;
1011

1112
/**
1213
* Class Visitor
@@ -67,6 +68,11 @@ class Visitor extends \Magento\Framework\Model\AbstractModel
6768
*/
6869
protected $indexerRegistry;
6970

71+
/**
72+
* @var RequestSafetyInterface
73+
*/
74+
private $requestSafety;
75+
7076
/**
7177
* @param \Magento\Framework\Model\Context $context
7278
* @param \Magento\Framework\Registry $registry
@@ -95,7 +101,8 @@ public function __construct(
95101
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
96102
array $ignoredUserAgents = [],
97103
array $ignores = [],
98-
array $data = []
104+
array $data = [],
105+
RequestSafetyInterface $requestSafety = null
99106
) {
100107
$this->session = $session;
101108
$this->httpHeader = $httpHeader;
@@ -105,6 +112,7 @@ public function __construct(
105112
$this->scopeConfig = $scopeConfig;
106113
$this->dateTime = $dateTime;
107114
$this->indexerRegistry = $indexerRegistry;
115+
$this->requestSafety = $requestSafety ?? ObjectManager::getInstance()->get(RequestSafetyInterface::class);
108116
}
109117

110118
/**
@@ -158,6 +166,10 @@ public function initByRequest($observer)
158166

159167
$this->setLastVisitAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
160168

169+
// prevent saving Visitor for safe methods, e.g. GET request
170+
if ($this->requestSafety->isSafeMethod()) {
171+
return $this;
172+
}
161173
if (!$this->getId()) {
162174
$this->setSessionId($this->session->getSessionId());
163175
$this->save();
@@ -177,7 +189,8 @@ public function initByRequest($observer)
177189
*/
178190
public function saveByRequest($observer)
179191
{
180-
if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) {
192+
// prevent saving Visitor for safe methods, e.g. GET request
193+
if ($this->skipRequestLogging || $this->requestSafety->isSafeMethod() || $this->isModuleIgnored($observer)) {
181194
return $this;
182195
}
183196

0 commit comments

Comments
 (0)