Skip to content

Commit 5683c42

Browse files
author
Oleksandr Iegorov
committed
Merge branch '2.2-develop' of github.com:magento/magento2ce into MAGETWO-69940
2 parents 7785933 + 9d6930c commit 5683c42

File tree

27 files changed

+677
-286
lines changed

27 files changed

+677
-286
lines changed

app/code/Magento/Checkout/view/frontend/web/js/sidebar.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ define([
99
'Magento_Customer/js/customer-data',
1010
'Magento_Ui/js/modal/alert',
1111
'Magento_Ui/js/modal/confirm',
12+
'underscore',
1213
'jquery/ui',
1314
'mage/decorate',
1415
'mage/collapsible',
1516
'mage/cookies'
16-
], function ($, authenticationPopup, customerData, alert, confirm) {
17+
], function ($, authenticationPopup, customerData, alert, confirm, _) {
1718
'use strict';
1819

1920
$.widget('mage.sidebar', {
@@ -219,6 +220,11 @@ define([
219220
* @param {HTMLElement} elem
220221
*/
221222
_updateItemQtyAfter: function (elem) {
223+
var productData = this._getProductById(Number(elem.data('cart-item')));
224+
225+
if (!_.isUndefined(productData)) {
226+
$(document).trigger('ajax:updateCartItemQty', productData['product_sku']);
227+
}
222228
this._hideItemButton(elem);
223229
},
224230

@@ -241,11 +247,24 @@ define([
241247
* @private
242248
*/
243249
_removeItemAfter: function (elem) {
244-
var productData = customerData.get('cart')().items.find(function (item) {
245-
return Number(elem.data('cart-item')) === Number(item['item_id']);
246-
});
250+
var productData = this._getProductById(Number(elem.data('cart-item')));
251+
252+
if (!_.isUndefined(productData)) {
253+
$(document).trigger('ajax:removeFromCart', productData['product_sku']);
254+
}
255+
},
247256

248-
$(document).trigger('ajax:removeFromCart', productData['product_sku']);
257+
/**
258+
* Retrieves product data by Id.
259+
*
260+
* @param {Number} productId - product Id
261+
* @returns {Object|undefined}
262+
* @private
263+
*/
264+
_getProductById: function (productId) {
265+
return _.find(customerData.get('cart')().items, function (item) {
266+
return productId === Number(item['item_id']);
267+
});
249268
},
250269

251270
/**

app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
require([
22
'jquery',
33
'Magento_Customer/js/customer-data',
4+
'underscore',
45
'domReady!'
5-
], function ($, customerData) {
6+
], function ($, customerData, _) {
67
'use strict';
78

89
var selectors = {
@@ -41,7 +42,7 @@ require([
4142
if (!(data && data.items && data.items.length && productId)) {
4243
return;
4344
}
44-
product = data.items.find(function (item) {
45+
product = _.find(data.items, function (item) {
4546
if (item['item_id'] === itemId) {
4647
return item['product_id'] === productId ||
4748
item['item_id'] === productId;

app/code/Magento/Customer/Model/Metadata/AttributeMetadataHydrator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Customer\Api\Data\OptionInterfaceFactory;
1212
use Magento\Customer\Api\Data\ValidationRuleInterface;
1313
use Magento\Customer\Api\Data\ValidationRuleInterfaceFactory;
14+
use Magento\Customer\Model\Data\AttributeMetadata;
1415
use Magento\Framework\Reflection\DataObjectProcessor;
1516

1617
/**
@@ -120,7 +121,7 @@ public function extract($attributeMetadata)
120121
{
121122
return $this->dataObjectProcessor->buildOutputDataArray(
122123
$attributeMetadata,
123-
AttributeMetadataInterface::class
124+
AttributeMetadata::class
124125
);
125126
}
126127
}

app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataHydratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function testExtract()
205205
->method('buildOutputDataArray')
206206
->with(
207207
$this->attributeMetadataMock,
208-
AttributeMetadataInterface::class
208+
AttributeMetadata::class
209209
)
210210
->willReturn($data);
211211
$this->assertSame(

app/code/Magento/Customer/view/frontend/templates/logout.phtml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
/** @var \Magento\Framework\View\Element\Template $block */
88
?>
99
<p><?= $block->escapeHtml(__('You have signed out and will go to our homepage in 5 seconds.')) ?></p>
10-
<script>
11-
require([
12-
"jquery",
13-
"mage/mage"
14-
], function($){
15-
16-
$($.mage.redirect("<?= $block->escapeJs($block->escapeUrl($block->getUrl())) ?>", "assign", 5000));
17-
18-
});
10+
<script type="text/x-magento-init">
11+
{
12+
"*": {
13+
"Magento_Customer/js/logout-redirect": {
14+
"url": "<?= $block->escapeJs($block->escapeUrl($block->getUrl())) ?>"
15+
}
16+
}
17+
}
1918
</script>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'mage/mage'
9+
], function ($) {
10+
'use strict';
11+
12+
return function (data) {
13+
$($.mage.redirect(data.url, 'assign', 5000));
14+
};
15+
});

app/code/Magento/Fedex/Model/Carrier.php

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
namespace Magento\Fedex\Model;
1010

1111
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\DataObject;
1213
use Magento\Framework\Module\Dir;
1314
use Magento\Framework\Serialize\Serializer\Json;
15+
use Magento\Framework\Webapi\Soap\ClientFactory;
1416
use Magento\Framework\Xml\Security;
1517
use Magento\Quote\Model\Quote\Address\RateRequest;
1618
use Magento\Shipping\Model\Carrier\AbstractCarrierOnline;
@@ -19,7 +21,6 @@
1921
/**
2022
* Fedex shipping implementation
2123
*
22-
* @author Magento Core Team <core@magentocommerce.com>
2324
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2425
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2526
*/
@@ -145,6 +146,11 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
145146
*/
146147
private $serializer;
147148

149+
/**
150+
* @var ClientFactory
151+
*/
152+
private $soapClientFactory;
153+
148154
/**
149155
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
150156
* @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
@@ -166,7 +172,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
166172
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
167173
* @param array $data
168174
* @param Json|null $serializer
169-
*
175+
* @param ClientFactory|null $soapClientFactory
170176
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
171177
*/
172178
public function __construct(
@@ -189,7 +195,8 @@ public function __construct(
189195
\Magento\Framework\Module\Dir\Reader $configReader,
190196
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
191197
array $data = [],
192-
Json $serializer = null
198+
Json $serializer = null,
199+
ClientFactory $soapClientFactory = null
193200
) {
194201
$this->_storeManager = $storeManager;
195202
$this->_productCollectionFactory = $productCollectionFactory;
@@ -216,6 +223,7 @@ public function __construct(
216223
$this->_rateServiceWsdl = $wsdlBasePath . 'RateService_v10.wsdl';
217224
$this->_trackServiceWsdl = $wsdlBasePath . 'TrackService_v' . self::$trackServiceVersion . '.wsdl';
218225
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
226+
$this->soapClientFactory = $soapClientFactory ?: ObjectManager::getInstance()->get(ClientFactory::class);
219227
}
220228

221229
/**
@@ -227,7 +235,7 @@ public function __construct(
227235
*/
228236
protected function _createSoapClient($wsdl, $trace = false)
229237
{
230-
$client = new \SoapClient($wsdl, ['trace' => $trace]);
238+
$client = $this->soapClientFactory->create($wsdl, ['trace' => $trace]);
231239
$client->__setLocation(
232240
$this->getConfigFlag(
233241
'sandbox_mode'
@@ -1264,7 +1272,7 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request)
12641272
$countriesOfManufacture[] = $product->getCountryOfManufacture();
12651273
}
12661274

1267-
$paymentType = $request->getIsReturn() ? 'RECIPIENT' : 'SENDER';
1275+
$paymentType = $this->getPaymentType($request);
12681276
$optionType = $request->getShippingMethod() == self::RATE_REQUEST_SMARTPOST
12691277
? 'SERVICE_DEFAULT' : $packageParams->getDeliveryConfirmation();
12701278
$requestClient = [
@@ -1750,4 +1758,18 @@ private function parseDate($timestamp)
17501758

17511759
return false;
17521760
}
1761+
1762+
/**
1763+
* Defines payment type by request.
1764+
* Two values are available: RECIPIENT or SENDER.
1765+
*
1766+
* @param DataObject $request
1767+
* @return string
1768+
*/
1769+
private function getPaymentType(DataObject $request): string
1770+
{
1771+
return $request->getIsReturn() && $request->getShippingMethod() !== self::RATE_REQUEST_SMARTPOST
1772+
? 'RECIPIENT'
1773+
: 'SENDER';
1774+
}
17531775
}

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@ protected function _prepareForm()
134134
$this->_addAttributesToForm($attributes, $fieldset);
135135

136136
$this->_form->addFieldNameSuffix('order[account]');
137-
$this->_form->setValues($this->getFormValues());
137+
138+
$formValues = $this->getFormValues();
139+
foreach ($attributes as $code => $attribute) {
140+
$defaultValue = $attribute->getDefaultValue();
141+
if (isset($defaultValue) && !isset($formValues[$code])) {
142+
$formValues[$code] = $defaultValue;
143+
}
144+
}
145+
$this->_form->setValues($formValues);
138146

139147
return $this;
140148
}

app/code/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ public function execute()
5555
$this->_initSession()->_processData();
5656
} catch (\Magento\Framework\Exception\LocalizedException $e) {
5757
$this->_reloadQuote();
58-
$this->messageManager->addError($e->getMessage());
58+
$this->messageManager->addErrorMessage($e->getMessage());
5959
} catch (\Exception $e) {
6060
$this->_reloadQuote();
61-
$this->messageManager->addException($e, $e->getMessage());
61+
$this->messageManager->addExceptionMessage($e, $e->getMessage());
6262
}
6363

6464
$asJson = $request->getParam('json');

app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Sales\Controller\Adminhtml\Order\Create;
78

9+
use Magento\Framework\Controller\ResultFactory;
810
use Magento\Framework\Exception\PaymentException;
911

1012
class Save extends \Magento\Sales\Controller\Adminhtml\Order\Create
1113
{
1214
/**
1315
* Saving quote and create order
1416
*
15-
* @return \Magento\Backend\Model\View\Result\Forward|\Magento\Backend\Model\View\Result\Redirect
17+
* @return \Magento\Framework\Controller\ResultInterface
1618
*
1719
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
1820
*/
1921
public function execute()
2022
{
21-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
22-
$resultRedirect = $this->resultRedirectFactory->create();
23+
$path = 'sales/*/';
24+
$pathParams = [];
25+
2326
try {
2427
// check if the creation of a new customer is allowed
2528
if (!$this->_authorization->isAllowed('Magento_Customer::manage')
@@ -49,31 +52,30 @@ public function execute()
4952
->createOrder();
5053

5154
$this->_getSession()->clearStorage();
52-
$this->messageManager->addSuccess(__('You created the order.'));
55+
$this->messageManager->addSuccessMessage(__('You created the order.'));
5356
if ($this->_authorization->isAllowed('Magento_Sales::actions_view')) {
54-
$resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]);
57+
$pathParams = ['order_id' => $order->getId()];
58+
$path = 'sales/order/view';
5559
} else {
56-
$resultRedirect->setPath('sales/order/index');
60+
$path = 'sales/order/index';
5761
}
5862
} catch (PaymentException $e) {
5963
$this->_getOrderCreateModel()->saveQuote();
6064
$message = $e->getMessage();
6165
if (!empty($message)) {
62-
$this->messageManager->addError($message);
66+
$this->messageManager->addErrorMessage($message);
6367
}
64-
$resultRedirect->setPath('sales/*/');
6568
} catch (\Magento\Framework\Exception\LocalizedException $e) {
6669
// customer can be created before place order flow is completed and should be stored in current session
67-
$this->_getSession()->setCustomerId($this->_getSession()->getQuote()->getCustomerId());
70+
$this->_getSession()->setCustomerId((int)$this->_getSession()->getQuote()->getCustomerId());
6871
$message = $e->getMessage();
6972
if (!empty($message)) {
70-
$this->messageManager->addError($message);
73+
$this->messageManager->addErrorMessage($message);
7174
}
72-
$resultRedirect->setPath('sales/*/');
7375
} catch (\Exception $e) {
74-
$this->messageManager->addException($e, __('Order saving error: %1', $e->getMessage()));
75-
$resultRedirect->setPath('sales/*/');
76+
$this->messageManager->addExceptionMessage($e, __('Order saving error: %1', $e->getMessage()));
7677
}
77-
return $resultRedirect;
78+
79+
return $this->resultRedirectFactory->create()->setPath($path, $pathParams);
7880
}
7981
}

0 commit comments

Comments
 (0)