Skip to content

Commit 82b1618

Browse files
author
Karpenko, Oleksandr
committed
Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-53630-2
2 parents b13993f + 2008804 commit 82b1618

File tree

32 files changed

+393
-89
lines changed

32 files changed

+393
-89
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Customer\Api\GroupRepositoryInterface;
1313
use Magento\Framework\Exception\CouldNotSaveException;
1414
use Magento\Framework\Exception\InputException;
15+
use Magento\Framework\Exception\TemporaryStateExceptionInterface;
1516

1617
/**
1718
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -137,6 +138,10 @@ public function add($sku, $customerGroupId, $price, $qty)
137138
try {
138139
$this->productRepository->save($product);
139140
} catch (\Exception $e) {
141+
if ($e instanceof TemporaryStateExceptionInterface) {
142+
// temporary state exception must be already localized
143+
throw $e;
144+
}
140145
throw new CouldNotSaveException(__('Could not save group price'));
141146
}
142147
return true;

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Magento\Framework\Api\ImageContentValidatorInterface;
1515
use Magento\Framework\Api\ImageProcessorInterface;
1616
use Magento\Framework\Api\SortOrder;
17+
use Magento\Framework\DB\Adapter\ConnectionException;
18+
use Magento\Framework\DB\Adapter\DeadlockException;
19+
use Magento\Framework\DB\Adapter\LockWaitException;
1720
use Magento\Framework\Exception\InputException;
1821
use Magento\Framework\Exception\LocalizedException;
1922
use Magento\Framework\Exception\NoSuchEntityException;
@@ -535,6 +538,24 @@ public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveO
535538
unset($this->instances[$product->getSku()]);
536539
unset($this->instancesById[$product->getId()]);
537540
$this->resourceModel->save($product);
541+
} catch (ConnectionException $exception) {
542+
throw new \Magento\Framework\Exception\TemporaryState\CouldNotSaveException(
543+
__('Database connection error'),
544+
$exception,
545+
$exception->getCode()
546+
);
547+
} catch (DeadlockException $exception) {
548+
throw new \Magento\Framework\Exception\TemporaryState\CouldNotSaveException(
549+
__('Database deadlock found when trying to get lock'),
550+
$exception,
551+
$exception->getCode()
552+
);
553+
} catch (LockWaitException $exception) {
554+
throw new \Magento\Framework\Exception\TemporaryState\CouldNotSaveException(
555+
__('Database lock wait timeout exceeded'),
556+
$exception,
557+
$exception->getCode()
558+
);
538559
} catch (\Magento\Eav\Model\Entity\Attribute\Exception $exception) {
539560
throw \Magento\Framework\Exception\InputException::invalidFieldValue(
540561
$exception->getAttributeCode(),

app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use Magento\Customer\Model\GroupManagement;
1414
use Magento\Framework\Exception\NoSuchEntityException;
15+
use Magento\Framework\Exception\TemporaryState\CouldNotSaveException;
1516

1617
/**
1718
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -393,6 +394,30 @@ public function testSetThrowsExceptionIfCantSave()
393394
$this->service->add('product_sku', 1, 100, 2);
394395
}
395396

397+
/**
398+
* @expectedException \Magento\Framework\Exception\TemporaryState\CouldNotSaveException
399+
*/
400+
public function testAddRethrowsTemporaryStateExceptionIfRecoverableErrorOccurred()
401+
{
402+
$group = $this->getMock(\Magento\Customer\Model\Data\Group::class, [], [], '', false);
403+
$group->expects($this->once())
404+
->method('getId')
405+
->willReturn(1);
406+
$this->productMock
407+
->expects($this->once())
408+
->method('getData')
409+
->with('tier_price')
410+
->will($this->returnValue([]));
411+
$this->groupRepositoryMock->expects($this->once())
412+
->method('getById')
413+
->willReturn($group);
414+
$this->repositoryMock->expects($this->once())
415+
->method('save')
416+
->willThrowException(new CouldNotSaveException(__('Lock wait timeout')));
417+
418+
$this->service->add('product_sku', 1, 100, 2);
419+
}
420+
396421
/**
397422
* @param string|int $price
398423
* @param string|float $qty

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory;
1313
use Magento\Framework\Api\Data\ImageContentInterface;
1414
use Magento\Framework\Api\SortOrder;
15+
use Magento\Framework\DB\Adapter\ConnectionException;
1516
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1617
use Magento\Store\Model\ScopeInterface;
1718

@@ -602,6 +603,36 @@ public function testSaveInvalidProductException()
602603
$this->model->save($this->productMock);
603604
}
604605

606+
/**
607+
* @expectedException \Magento\Framework\Exception\TemporaryState\CouldNotSaveException
608+
* @expectedExceptionMessage Database connection error
609+
*/
610+
public function testSaveThrowsTemporaryStateExceptionIfDatabaseConnectionErrorOccurred()
611+
{
612+
$this->productFactoryMock->expects($this->any())
613+
->method('create')
614+
->will($this->returnValue($this->productMock));
615+
$this->initializationHelperMock->expects($this->never())
616+
->method('initialize');
617+
$this->resourceModelMock->expects($this->once())
618+
->method('validate')
619+
->with($this->productMock)
620+
->willReturn(true);
621+
$this->resourceModelMock->expects($this->once())
622+
->method('save')
623+
->with($this->productMock)
624+
->willThrowException(new ConnectionException('Connection lost'));
625+
$this->extensibleDataObjectConverterMock
626+
->expects($this->once())
627+
->method('toNestedArray')
628+
->will($this->returnValue($this->productData));
629+
$this->productMock->expects($this->once())
630+
->method('getWebsiteIds')
631+
->willReturn([]);
632+
633+
$this->model->save($this->productMock);
634+
}
635+
605636
public function testDelete()
606637
{
607638
$this->productMock->expects($this->exactly(2))->method('getSku')->willReturn('product-42');

app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
<!-- post-code field has custom UI component -->
210210
<item name="component" xsi:type="string">Magento_Ui/js/form/element/post-code</item>
211211
<item name="validation" xsi:type="array">
212-
<item name="required-entry" xsi:type="string">true</item>
212+
<item name="required-entry" xsi:type="boolean">true</item>
213213
</item>
214214
</item>
215215
<item name="company" xsi:type="array">

app/code/Magento/Checkout/view/frontend/web/js/model/place-order.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ define(
1919
).fail(
2020
function (response) {
2121
errorProcessor.process(response, messageContainer);
22+
}
23+
).always(
24+
function () {
2225
fullScreenLoader.stopLoader();
2326
}
2427
);

app/code/Magento/Checkout/view/frontend/web/js/model/quote.js

Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,78 @@
22
* Copyright © 2016 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5-
define(
6-
['ko'],
7-
function (ko) {
8-
'use strict';
9-
var billingAddress = ko.observable(null);
10-
var shippingAddress = ko.observable(null);
11-
var shippingMethod = ko.observable(null);
12-
var paymentMethod = ko.observable(null);
13-
var quoteData = window.checkoutConfig.quoteData;
14-
var basePriceFormat = window.checkoutConfig.basePriceFormat;
15-
var priceFormat = window.checkoutConfig.priceFormat;
16-
var storeCode = window.checkoutConfig.storeCode;
17-
var totalsData = window.checkoutConfig.totalsData;
18-
var totals = ko.observable(totalsData);
19-
var collectedTotals = ko.observable({});
20-
return {
21-
totals: totals,
22-
shippingAddress: shippingAddress,
23-
shippingMethod: shippingMethod,
24-
billingAddress: billingAddress,
25-
paymentMethod: paymentMethod,
26-
guestEmail: null,
5+
define([
6+
'ko',
7+
'underscore'
8+
], function (ko, _) {
9+
'use strict';
2710

28-
getQuoteId: function() {
29-
return quoteData.entity_id;
30-
},
31-
isVirtual: function() {
32-
return !!Number(quoteData.is_virtual);
33-
},
34-
getPriceFormat: function() {
35-
return priceFormat;
36-
},
37-
getBasePriceFormat: function() {
38-
return basePriceFormat;
39-
},
40-
getItems: function() {
41-
return window.checkoutConfig.quoteItemData;
42-
},
43-
getTotals: function() {
44-
return totals;
45-
},
46-
setTotals: function(totalsData) {
47-
if (_.isObject(totalsData) && _.isObject(totalsData.extension_attributes)) {
48-
_.each(totalsData.extension_attributes, function(element, index) {
49-
totalsData[index] = element;
50-
});
51-
}
52-
totals(totalsData);
53-
this.setCollectedTotals('subtotal_with_discount', parseFloat(totalsData.subtotal_with_discount));
54-
},
55-
setPaymentMethod: function(paymentMethodCode) {
56-
paymentMethod(paymentMethodCode);
57-
},
58-
getPaymentMethod: function() {
59-
return paymentMethod;
60-
},
61-
getStoreCode: function() {
62-
return storeCode;
63-
},
64-
setCollectedTotals: function(code, value) {
65-
var totals = collectedTotals();
66-
totals[code] = value;
67-
collectedTotals(totals);
68-
},
69-
getCalculatedTotal: function() {
70-
var total = 0.;
71-
_.each(collectedTotals(), function(value) {
72-
total += value;
11+
var billingAddress = ko.observable(null);
12+
var shippingAddress = ko.observable(null);
13+
var shippingMethod = ko.observable(null);
14+
var paymentMethod = ko.observable(null);
15+
var quoteData = window.checkoutConfig.quoteData;
16+
var basePriceFormat = window.checkoutConfig.basePriceFormat;
17+
var priceFormat = window.checkoutConfig.priceFormat;
18+
var storeCode = window.checkoutConfig.storeCode;
19+
var totalsData = window.checkoutConfig.totalsData;
20+
var totals = ko.observable(totalsData);
21+
var collectedTotals = ko.observable({});
22+
return {
23+
totals: totals,
24+
shippingAddress: shippingAddress,
25+
shippingMethod: shippingMethod,
26+
billingAddress: billingAddress,
27+
paymentMethod: paymentMethod,
28+
guestEmail: null,
29+
30+
getQuoteId: function() {
31+
return quoteData.entity_id;
32+
},
33+
isVirtual: function() {
34+
return !!Number(quoteData.is_virtual);
35+
},
36+
getPriceFormat: function() {
37+
return priceFormat;
38+
},
39+
getBasePriceFormat: function() {
40+
return basePriceFormat;
41+
},
42+
getItems: function() {
43+
return window.checkoutConfig.quoteItemData;
44+
},
45+
getTotals: function() {
46+
return totals;
47+
},
48+
setTotals: function(totalsData) {
49+
if (_.isObject(totalsData) && _.isObject(totalsData.extension_attributes)) {
50+
_.each(totalsData.extension_attributes, function(element, index) {
51+
totalsData[index] = element;
7352
});
74-
return total;
7553
}
76-
};
77-
}
78-
);
54+
totals(totalsData);
55+
this.setCollectedTotals('subtotal_with_discount', parseFloat(totalsData.subtotal_with_discount));
56+
},
57+
setPaymentMethod: function(paymentMethodCode) {
58+
paymentMethod(paymentMethodCode);
59+
},
60+
getPaymentMethod: function() {
61+
return paymentMethod;
62+
},
63+
getStoreCode: function() {
64+
return storeCode;
65+
},
66+
setCollectedTotals: function(code, value) {
67+
var totals = collectedTotals();
68+
totals[code] = value;
69+
collectedTotals(totals);
70+
},
71+
getCalculatedTotal: function() {
72+
var total = 0.;
73+
_.each(collectedTotals(), function(value) {
74+
total += value;
75+
});
76+
return total;
77+
}
78+
};
79+
});

app/code/Magento/Sales/Model/ResourceModel/Order/Item.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
namespace Magento\Sales\Model\ResourceModel\Order;
77

88
use Magento\Sales\Model\ResourceModel\EntityAbstract as SalesResource;
9+
use Magento\Sales\Model\Spi\OrderItemResourceInterface;
910

1011
/**
1112
* Flat sales order item resource
1213
*/
13-
class Item extends SalesResource
14+
class Item extends SalesResource implements OrderItemResourceInterface
1415
{
1516
/**
1617
* Event prefix

app/code/Magento/Sales/view/adminhtml/templates/order/view/info.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ $orderStoreDate = $block->formatDate(
9090
<?php if ($_order->getRemoteIp() && $block->shouldDisplayCustomerIp()): ?>
9191
<tr>
9292
<th><?php /* @escapeNotVerified */ echo __('Placed from IP') ?></th>
93-
<td><?php /* @escapeNotVerified */ echo $_order->getRemoteIp(); echo($_order->getXForwardedFor()) ? ' (' . $block->escapeHtml($_order->getXForwardedFor()) . ')' : ''; ?></td>
93+
<td><?php echo $block->escapeHtml($_order->getRemoteIp()); echo($_order->getXForwardedFor()) ? ' (' . $block->escapeHtml($_order->getXForwardedFor()) . ')' : ''; ?></td>
9494
</tr>
9595
<?php endif; ?>
9696
<?php if ($_order->getGlobalCurrencyCode() != $_order->getBaseCurrencyCode()): ?>

app/code/Magento/Sales/view/frontend/email/order_new.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"layout handle=\"sales_email_order_items\" order=$order area=\"frontend\"":"Order Items Grid",
1313
"var payment_html|raw":"Payment Details",
1414
"var formattedShippingAddress|raw":"Shipping Address",
15-
"var order.getShippingDescription()":"Shipping Description"
15+
"var order.getShippingDescription()":"Shipping Description",
1616
"var shipping_msg":"Shipping message"
1717
} @-->
1818

0 commit comments

Comments
 (0)