Skip to content

Commit 8d98c7e

Browse files
author
Robert He
committed
Merge branch 'develop' of https://github.corp.magento.com/magento2/magento2ce into develop
2 parents 8950a8e + 3392976 commit 8d98c7e

File tree

63 files changed

+2244
-592
lines changed

Some content is hidden

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

63 files changed

+2244
-592
lines changed

app/code/Magento/Braintree/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"magento/module-directory": "100.0.*",
1717
"magento/module-theme": "100.0.*",
1818
"magento/framework": "100.0.*",
19-
"braintree/braintree_php": "2.39.0"
19+
"braintree/braintree_php": "3.7.0"
2020
},
2121
"suggest": {
2222
"magento/module-checkout-agreements": "100.0.*"

app/code/Magento/Catalog/view/frontend/web/js/product/list/toolbar.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,16 @@ define([
6161
},
6262

6363
changeUrl: function (paramName, paramValue, defaultValue) {
64+
var decode = window.decodeURIComponent;
6465
var urlPaths = this.options.url.split('?'),
6566
baseUrl = urlPaths[0],
6667
urlParams = urlPaths[1] ? urlPaths[1].split('&') : [],
6768
paramData = {},
6869
parameters;
6970
for (var i = 0; i < urlParams.length; i++) {
7071
parameters = urlParams[i].split('=');
71-
paramData[parameters[0]] = parameters[1] !== undefined
72-
? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20'))
72+
paramData[decode(parameters[0])] = parameters[1] !== undefined
73+
? decode(parameters[1].replace(/\+/g, '%20'))
7374
: '';
7475
}
7576
paramData[paramName] = paramValue;

app/code/Magento/CatalogSearch/view/frontend/templates/advanced/result.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<?php else: ?>
2424
<div class="message error">
2525
<div>
26-
<?php /* @escapeNotVerified */ echo __('We can\'t find any items matching these search criteria.');?> <a href="<?php /* @escapeNotVerified */ echo $block->getFormUrl(); ?>"><?php /* @escapeNotVerified */ echo __('Modify your search'); ?></a>
26+
<?php /* @escapeNotVerified */ echo __('We can\'t find any items matching these search criteria.');?> <a href="<?php /* @escapeNotVerified */ echo $block->getFormUrl(); ?>"><?php /* @escapeNotVerified */ echo __('Modify your search.'); ?></a>
2727
</div>
2828
</div>
2929
<?php endif; ?>
@@ -44,7 +44,7 @@
4444
<div class="message notice">
4545
<div>
4646
<?php /* @escapeNotVerified */ echo __("Don't see what you're looking for?"); ?>
47-
<a href="<?php /* @escapeNotVerified */ echo $block->getFormUrl(); ?>"><?php /* @escapeNotVerified */ echo __('Modify your search'); ?></a>
47+
<a href="<?php /* @escapeNotVerified */ echo $block->getFormUrl(); ?>"><?php /* @escapeNotVerified */ echo __('Modify your search.'); ?></a>
4848
</div>
4949
</div>
5050
<?php endif; ?>

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public function afterInitialize(
5151
$attributes = $this->request->getParam('attributes');
5252
if ($product->getTypeId() == ConfigurableProduct::TYPE_CODE && !empty($attributes)) {
5353
$setId = $this->request->getPost('new-variations-attribute-set-id');
54-
$product->setAttributeSetId($setId);
54+
if ($setId) {
55+
$product->setAttributeSetId($setId);
56+
}
5557
$this->productType->setUsedProductAttributeIds($attributes, $product);
5658

5759
$product->setNewVariationsAttributeSetId($setId);

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ public function getFinalPrice($qty, $product)
2222
return $product->getCalculatedFinalPrice();
2323
}
2424
if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) {
25-
return parent::getFinalPrice($qty, $product->getCustomOption('simple_product')->getProduct());
25+
$finalPrice = parent::getFinalPrice($qty, $product->getCustomOption('simple_product')->getProduct());
2626
} else {
2727
$priceInfo = $product->getPriceInfo();
2828
$finalPrice = $priceInfo->getPrice('final_price')->getAmount()->getValue();
29-
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
30-
$finalPrice = max(0, $finalPrice);
31-
$product->setFinalPrice($finalPrice);
32-
33-
return $finalPrice;
3429
}
30+
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
31+
$finalPrice = max(0, $finalPrice);
32+
$product->setFinalPrice($finalPrice);
33+
34+
return $finalPrice;
3535
}
3636

3737
/**

app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Filters.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function update(UiComponentInterface $component)
4343
return;
4444
}
4545

46-
$attributeIds = $component->getContext()->getRequestParam('attribute_ids');
47-
if ($attributeIds) {
48-
foreach ($this->getAttributes($attributeIds) as $attribute) {
46+
$attributeCodes = $component->getContext()->getRequestParam('attributes_codes');
47+
if ($attributeCodes) {
48+
foreach ($this->getAttributes($attributeCodes) as $attribute) {
4949
$filter = $this->filterFactory->create($attribute, $component->getContext());
5050
$filter->prepare();
5151
$component->addComponent($attribute->getAttributeCode(), $filter);
@@ -54,12 +54,12 @@ public function update(UiComponentInterface $component)
5454
}
5555

5656
/**
57-
* @param array $attributeIds
57+
* @param array $attributeCodes
5858
* @return mixed
5959
*/
60-
protected function getAttributes($attributeIds)
60+
protected function getAttributes($attributeCodes)
6161
{
6262
$attributeCollection = $this->attributeCollectionFactory->create();
63-
return $attributeCollection->addFieldToFilter('attribute_code', ['in' => $attributeIds]);
63+
return $attributeCollection->addFieldToFilter('attribute_code', ['in' => $attributeCodes]);
6464
}
6565
}

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/options/price-type-handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ define([
2727
}
2828
this.hideWarning();
2929
$(this.messageSelector).notification('add', {
30-
message: $.mage.__('We can\'t save custom-defined options with price type "percent" for ' +
30+
message: $.mage.__('Custom options with price type "percent" is not available for ' +
3131
'configurable product.'),
32-
error: true,
32+
error: false,
3333
messageContainer: this.messageSelector
3434
});
3535
},

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/product-grid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ define([
245245
}),
246246
usedProductIds = _.values(this.variationsComponent().productAttributesMap);
247247

248-
if (usedProductIds) {
248+
if (usedProductIds && usedProductIds.length > 0) {
249249
filterModifier['entity_id'] = {
250250
'condition_type': 'nin', value: usedProductIds
251251
};
Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Integration\Controller\Adminhtml\Integration;
87

98
use Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info;
109
use Magento\Framework\Exception\IntegrationException;
10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Integration\Model\Integration as IntegrationModel;
1112

1213
class Save extends \Magento\Integration\Controller\Adminhtml\Integration
1314
{
@@ -30,7 +31,6 @@ protected function _redirectOnSaveError()
3031
* Save integration action.
3132
*
3233
* @return void
33-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
3434
*/
3535
public function execute()
3636
{
@@ -51,40 +51,11 @@ public function execute()
5151
$this->_redirect('*/*');
5252
return;
5353
}
54-
}
55-
/** @var array $data */
56-
$data = $this->getRequest()->getPostValue();
57-
if (!empty($data)) {
58-
if (!isset($data['resource'])) {
59-
$integrationData['resource'] = [];
60-
}
61-
$integrationData = array_merge($integrationData, $data);
62-
if (!isset($integrationData[Info::DATA_ID])) {
63-
$integration = $this->_integrationService->create($integrationData);
64-
} else {
65-
$integration = $this->_integrationService->update($integrationData);
66-
}
67-
if (!$this->getRequest()->isXmlHttpRequest()) {
68-
$this->messageManager->addSuccess(
69-
__(
70-
'The integration \'%1\' has been saved.',
71-
$this->escaper->escapeHtml($integration->getName())
72-
)
73-
);
74-
}
75-
if ($this->getRequest()->isXmlHttpRequest()) {
76-
$isTokenExchange = $integration->getEndpoint() && $integration->getIdentityLinkUrl() ? '1' : '0';
77-
$this->getResponse()->representJson(
78-
$this->jsonHelper->jsonEncode(
79-
['integrationId' => $integration->getId(), 'isTokenExchange' => $isTokenExchange]
80-
)
81-
);
82-
} else {
83-
$this->_redirect('*/*/');
54+
if ($integrationData[Info::DATA_SETUP_TYPE] == IntegrationModel::TYPE_CONFIG) {
55+
throw new LocalizedException(__('Cannot edit integrations created via config file.'));
8456
}
85-
} else {
86-
$this->messageManager->addError(__('The integration was not saved.'));
8757
}
58+
$this->processData($integrationData);
8859
} catch (IntegrationException $e) {
8960
$this->messageManager->addError($this->escaper->escapeHtml($e->getMessage()));
9061
$this->_getSession()->setIntegrationData($integrationData);
@@ -98,4 +69,45 @@ public function execute()
9869
$this->_redirectOnSaveError();
9970
}
10071
}
72+
73+
/**
74+
* Save integration data.
75+
*
76+
* @param array $integrationData
77+
* @return void
78+
*/
79+
private function processData($integrationData)
80+
{
81+
/** @var array $data */
82+
$data = $this->getRequest()->getPostValue();
83+
if (!empty($data)) {
84+
if (!isset($data['resource'])) {
85+
$integrationData['resource'] = [];
86+
}
87+
$integrationData = array_merge($integrationData, $data);
88+
if (!isset($integrationData[Info::DATA_ID])) {
89+
$integration = $this->_integrationService->create($integrationData);
90+
} else {
91+
$integration = $this->_integrationService->update($integrationData);
92+
}
93+
if (!$this->getRequest()->isXmlHttpRequest()) {
94+
$this->messageManager->addSuccess(
95+
__(
96+
'The integration \'%1\' has been saved.',
97+
$this->escaper->escapeHtml($integration->getName())
98+
)
99+
);
100+
$this->_redirect('*/*/');
101+
} else {
102+
$isTokenExchange = $integration->getEndpoint() && $integration->getIdentityLinkUrl() ? '1' : '0';
103+
$this->getResponse()->representJson(
104+
$this->jsonHelper->jsonEncode(
105+
['integrationId' => $integration->getId(), 'isTokenExchange' => $isTokenExchange]
106+
)
107+
);
108+
}
109+
} else {
110+
$this->messageManager->addError(__('The integration was not saved.'));
111+
}
112+
}
101113
}

app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/SaveTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,31 @@ public function testSaveActionExceptionDuringServiceCreation()
188188
$integrationController = $this->_createIntegrationController('Save');
189189
$integrationController->execute();
190190
}
191+
192+
public function testSaveActionExceptionOnIntegrationsCreatedFromConfigFile()
193+
{
194+
$exceptionMessage = 'Cannot edit integrations created via config file.';
195+
$intData = new \Magento\Framework\DataObject(
196+
[
197+
Info::DATA_NAME => 'nameTest',
198+
Info::DATA_ID => self::INTEGRATION_ID,
199+
'id' => self::INTEGRATION_ID,
200+
Info::DATA_EMAIL => 'test@magento.com',
201+
Info::DATA_ENDPOINT => 'http://magento.ll/endpoint',
202+
Info::DATA_SETUP_TYPE => IntegrationModel::TYPE_CONFIG,
203+
]
204+
);
205+
206+
$this->_requestMock->expects($this->any())->method('getParam')->will($this->returnValue(self::INTEGRATION_ID));
207+
$this->_integrationSvcMock
208+
->expects($this->once())
209+
->method('get')
210+
->with(self::INTEGRATION_ID)
211+
->will($this->returnValue($intData));
212+
213+
// Verify error
214+
$this->_messageManager->expects($this->once())->method('addError')->with($this->equalTo($exceptionMessage));
215+
$integrationContr = $this->_createIntegrationController('Save');
216+
$integrationContr->execute();
217+
}
191218
}

0 commit comments

Comments
 (0)