Skip to content

Commit 46854c1

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-64413
2 parents d55fa28 + c993777 commit 46854c1

File tree

57 files changed

+2401
-160
lines changed

Some content is hidden

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

57 files changed

+2401
-160
lines changed

app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Payment\Model\IframeConfigProvider;
1717
use Magento\Quote\Api\CartManagementInterface;
1818
use Magento\Framework\Exception\LocalizedException;
19+
use Psr\Log\LoggerInterface;
20+
use Magento\Framework\App\ObjectManager;
1921

2022
/**
2123
* Class Place
@@ -44,26 +46,36 @@ class Place extends Payment
4446
*/
4547
protected $jsonHelper;
4648

49+
/**
50+
* Logger for exception details
51+
*
52+
* @var LoggerInterface
53+
*/
54+
private $logger;
55+
4756
/**
4857
* @param Context $context
4958
* @param Registry $coreRegistry
5059
* @param DataFactory $dataFactory
5160
* @param CartManagementInterface $cartManagement
5261
* @param Onepage $onepageCheckout
5362
* @param JsonHelper $jsonHelper
63+
* @param LoggerInterface|null $logger
5464
*/
5565
public function __construct(
5666
Context $context,
5767
Registry $coreRegistry,
5868
DataFactory $dataFactory,
5969
CartManagementInterface $cartManagement,
6070
Onepage $onepageCheckout,
61-
JsonHelper $jsonHelper
71+
JsonHelper $jsonHelper,
72+
LoggerInterface $logger = null
6273
) {
6374
$this->eventManager = $context->getEventManager();
6475
$this->cartManagement = $cartManagement;
6576
$this->onepageCheckout = $onepageCheckout;
6677
$this->jsonHelper = $jsonHelper;
78+
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
6779
parent::__construct($context, $coreRegistry, $dataFactory);
6880
}
6981

@@ -127,9 +139,11 @@ protected function placeCheckoutOrder()
127139
]
128140
);
129141
} catch (LocalizedException $exception) {
142+
$this->logger->critical($exception);
130143
$result->setData('error', true);
131144
$result->setData('error_messages', $exception->getMessage());
132145
} catch (\Exception $exception) {
146+
$this->logger->critical($exception);
133147
$result->setData('error', true);
134148
$result->setData(
135149
'error_messages',

app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/PlaceTest.php

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Payment\Model\IframeConfigProvider;
2121
use Magento\Quote\Api\CartManagementInterface;
2222
use Magento\Quote\Model\Quote;
23+
use Magento\Framework\Exception\LocalizedException;
2324

2425
/**
2526
* Class PlaceTest
@@ -94,6 +95,11 @@ class PlaceTest extends \PHPUnit_Framework_TestCase
9495
*/
9596
protected $quoteMock;
9697

98+
/**
99+
* @var \PHPUnit_Framework_MockObject_MockObject
100+
*/
101+
private $loggerMock;
102+
97103
/**
98104
* @var CheckoutSession|\PHPUnit_Framework_MockObject_MockObject
99105
*/
@@ -152,6 +158,9 @@ protected function setUp()
152158
->getMockBuilder(\Magento\Framework\App\Response\Http::class)
153159
->disableOriginalConstructor()
154160
->getMockForAbstractClass();
161+
$this->loggerMock = $this
162+
->getMockBuilder(\Psr\Log\LoggerInterface::class)
163+
->getMock();
155164

156165
$this->objectManager = new ObjectManager($this);
157166
$this->placeOrderController = $this->objectManager->getObject(
@@ -165,6 +174,7 @@ protected function setUp()
165174
'cartManagement' => $this->cartManagementMock,
166175
'onepageCheckout' => $this->onepageCheckout,
167176
'jsonHelper' => $this->jsonHelperMock,
177+
'logger' => $this->loggerMock,
168178
]
169179
);
170180
}
@@ -214,13 +224,15 @@ public function testExecute(
214224
* @param $controller
215225
* @param $quoteId
216226
* @param $result
227+
* @param \Exception $exception Exception to check
217228
* @dataProvider textExecuteFailedPlaceOrderDataProvider
218229
*/
219230
public function testExecuteFailedPlaceOrder(
220231
$paymentMethod,
221232
$controller,
222233
$quoteId,
223-
$result
234+
$result,
235+
$exception
224236
) {
225237
$this->requestMock->expects($this->at(0))
226238
->method('getParam')
@@ -238,7 +250,11 @@ public function testExecuteFailedPlaceOrder(
238250

239251
$this->cartManagementMock->expects($this->once())
240252
->method('placeOrder')
241-
->willThrowException(new \Exception());
253+
->willThrowException($exception);
254+
255+
$this->loggerMock->expects($this->once())
256+
->method('critical')
257+
->with($exception);
242258

243259
$this->jsonHelperMock->expects($this->any())
244260
->method('jsonEncode')
@@ -278,19 +294,35 @@ public function textExecuteDataProvider()
278294
*/
279295
public function textExecuteFailedPlaceOrderDataProvider()
280296
{
281-
$objectFailed = new \Magento\Framework\DataObject();
282-
$objectFailed->setData('error', true);
283-
$objectFailed->setData(
284-
'error_messages',
285-
__('An error occurred on the server. Please try to place the order again.')
297+
$objectFailed1 = new \Magento\Framework\DataObject(
298+
[
299+
'error' => true,
300+
'error_messages' => __('An error occurred on the server. Please try to place the order again.')
301+
]
302+
);
303+
$generalException = new \Exception('Exception logging will save the world!');
304+
$localizedException = new LocalizedException(__('Electronic payments save the trees.'));
305+
$objectFailed2 = new \Magento\Framework\DataObject(
306+
[
307+
'error' => true,
308+
'error_messages' => $localizedException->getMessage()
309+
]
286310
);
287311

288312
return [
289313
[
290314
['method' => 'authorizenet_directpost'],
291315
IframeConfigProvider::CHECKOUT_IDENTIFIER,
292316
1,
293-
$objectFailed
317+
$objectFailed1,
318+
$generalException,
319+
],
320+
[
321+
['method' => 'authorizenet_directpost'],
322+
IframeConfigProvider::CHECKOUT_IDENTIFIER,
323+
1,
324+
$objectFailed2,
325+
$localizedException,
294326
],
295327
];
296328
}

app/code/Magento/Braintree/Controller/Paypal/PlaceOrder.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Magento\Framework\Controller\ResultFactory;
1212
use Magento\Framework\Exception\LocalizedException;
1313
use Magento\Braintree\Gateway\Config\PayPal\Config;
14+
use Psr\Log\LoggerInterface;
15+
use Magento\Framework\App\ObjectManager;
1416

1517
/**
1618
* Class PlaceOrder
@@ -22,22 +24,32 @@ class PlaceOrder extends AbstractAction
2224
*/
2325
private $orderPlace;
2426

27+
/**
28+
* Logger for exception details
29+
*
30+
* @var LoggerInterface
31+
*/
32+
private $logger;
33+
2534
/**
2635
* Constructor
2736
*
2837
* @param Context $context
2938
* @param Config $config
3039
* @param Session $checkoutSession
3140
* @param Helper\OrderPlace $orderPlace
41+
* @param LoggerInterface|null $logger
3242
*/
3343
public function __construct(
3444
Context $context,
3545
Config $config,
3646
Session $checkoutSession,
37-
Helper\OrderPlace $orderPlace
47+
Helper\OrderPlace $orderPlace,
48+
LoggerInterface $logger = null
3849
) {
3950
parent::__construct($context, $config, $checkoutSession);
4051
$this->orderPlace = $orderPlace;
52+
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
4153
}
4254

4355
/**
@@ -58,6 +70,7 @@ public function execute()
5870
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
5971
return $resultRedirect->setPath('checkout/onepage/success', ['_secure' => true]);
6072
} catch (\Exception $e) {
73+
$this->logger->critical($e);
6174
$this->messageManager->addExceptionMessage($e, $e->getMessage());
6275
}
6376

app/code/Magento/Braintree/Test/Unit/Controller/Paypal/PlaceOrderTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class PlaceOrderTest extends \PHPUnit_Framework_TestCase
6060
*/
6161
private $placeOrder;
6262

63+
/**
64+
* @var \PHPUnit_Framework_MockObject_MockObject
65+
*/
66+
private $loggerMock;
67+
6368
protected function setUp()
6469
{
6570
/** @var Context|\PHPUnit_Framework_MockObject_MockObject $contextMock */
@@ -94,11 +99,15 @@ protected function setUp()
9499
->method('getMessageManager')
95100
->willReturn($this->messageManagerMock);
96101

102+
$this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
103+
->disableOriginalConstructor()
104+
->getMock();
97105
$this->placeOrder = new PlaceOrder(
98106
$contextMock,
99107
$this->configMock,
100108
$this->checkoutSessionMock,
101-
$this->orderPlaceMock
109+
$this->orderPlaceMock,
110+
$this->loggerMock
102111
);
103112
}
104113

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

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Catalog\Api\Data\ProductAttributeInterface;
99
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
10+
use Magento\Eav\Model\Entity\AttributeCache;
1011
use Magento\Framework\Setup\UpgradeDataInterface;
1112
use Magento\Framework\Setup\ModuleContextInterface;
1213
use Magento\Framework\Setup\ModuleDataSetupInterface;
@@ -34,16 +35,26 @@ class UpgradeData implements UpgradeDataInterface
3435
*/
3536
private $eavSetupFactory;
3637

38+
/**
39+
* @var AttributeCache
40+
*/
41+
private $attributeCache;
42+
3743
/**
3844
* Init
3945
*
4046
* @param CategorySetupFactory $categorySetupFactory
4147
* @param EavSetupFactory $eavSetupFactory
48+
* @param AttributeCache $attributeCache
4249
*/
43-
public function __construct(CategorySetupFactory $categorySetupFactory, EavSetupFactory $eavSetupFactory)
44-
{
50+
public function __construct(
51+
CategorySetupFactory $categorySetupFactory,
52+
EavSetupFactory $eavSetupFactory,
53+
AttributeCache $attributeCache
54+
) {
4555
$this->categorySetupFactory = $categorySetupFactory;
4656
$this->eavSetupFactory = $eavSetupFactory;
57+
$this->attributeCache = $attributeCache;
4758
}
4859

4960
/**
@@ -135,19 +146,24 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
135146
}
136147

137148
if (version_compare($context->getVersion(), '2.0.4') < 0) {
149+
$mediaBackendType = 'static';
150+
$mediaBackendModel = null;
138151
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
139152
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
140153
$categorySetup->updateAttribute(
141154
'catalog_product',
142155
'media_gallery',
143156
'backend_type',
144-
'static'
157+
$mediaBackendType
145158
);
146159
$categorySetup->updateAttribute(
147160
'catalog_product',
148161
'media_gallery',
149-
'backend_model'
162+
'backend_model',
163+
$mediaBackendModel
150164
);
165+
166+
$this->changeMediaGalleryAttributeInCache($mediaBackendType, $mediaBackendModel);
151167
}
152168

153169
if (version_compare($context->getVersion(), '2.0.5', '<')) {
@@ -340,10 +356,10 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
340356
]
341357
);
342358
}
343-
359+
344360
if (version_compare($context->getVersion(), '2.0.7') < 0) {
345361
/** @var EavSetup $eavSetup */
346-
$eavSetup= $this->eavSetupFactory->create(['setup' => $setup]);
362+
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
347363

348364
$eavSetup->updateAttribute(
349365
ProductAttributeInterface::ENTITY_TYPE_CODE,
@@ -381,4 +397,25 @@ private function changePriceAttributeDefaultScope($categorySetup)
381397

382398
}
383399
}
400+
401+
/**
402+
* @param string $mediaBackendType
403+
* @param string $mediaBackendModel
404+
* @return void
405+
*/
406+
private function changeMediaGalleryAttributeInCache($mediaBackendType, $mediaBackendModel)
407+
{
408+
// need to do, because media_gallery has backend model in cache.
409+
$catalogProductAttributes = $this->attributeCache->getAttributes('catalog_product', '0-0');
410+
411+
if (is_array($catalogProductAttributes)) {
412+
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $catalogProductAttribute */
413+
foreach ($catalogProductAttributes as $catalogProductAttribute) {
414+
if ($catalogProductAttribute->getAttributeCode() == 'media_gallery') {
415+
$catalogProductAttribute->setBackendModel($mediaBackendModel);
416+
$catalogProductAttribute->setBackendType($mediaBackendType);
417+
}
418+
}
419+
}
420+
}
384421
}

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ window.setRowVisibility = setRowVisibility;
337337
window.showDefaultRows = showDefaultRows;
338338
window.switchDefaultValueField = switchDefaultValueField;
339339
window.switchIsFilterable = switchIsFilterable;
340-
window.switchIsFilterable = switchIsFilterable;
341340
window.bindAttributeInputType = bindAttributeInputType;
342341
window.checkOptionsPanelVisibility = checkOptionsPanelVisibility;
343342
window.getFrontTab = getFrontTab;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +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"' : '' ?>>
22+
class="price-wrapper <?php /* @escapeNotVerified */ echo $block->getPriceWrapperCss(); ?>">
2423
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
2524
</span>
2625
<?php if ($block->hasAdjustmentsHtml()): ?>
2726
<?php echo $block->getAdjustmentsHtml() ?>
2827
<?php endif; ?>
2928
<?php if ($block->getSchema()): ?>
29+
<meta itemprop="price" content="<?php /* @escapeNotVerified */ echo $block->getDisplayValue(); ?>" />
3030
<meta itemprop="priceCurrency" content="<?php /* @escapeNotVerified */ echo $block->getDisplayCurrencyCode()?>" />
3131
<?php endif; ?>
3232
</span>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ define([
5757

5858
return Component.extend({
5959
defaults: {
60-
template: 'Magento_Checkout/shipping'
60+
template: 'Magento_Checkout/shipping',
61+
shippingFormTemplate: 'Magento_Checkout/shipping-address/form',
62+
shippingMethodListTemplate: 'Magento_Checkout/shipping-address/shipping-method-list',
63+
shippingMethodItemTemplate: 'Magento_Checkout/shipping-address/shipping-method-item'
6164
},
6265
visible: ko.observable(!quote.isVirtual()),
6366
errorValidationMessage: ko.observable(false),

0 commit comments

Comments
 (0)