Skip to content

Commit 61c086c

Browse files
Merge branch '2.2-develop' of github.com:magento/magento2ce into MAGETWO-87169
2 parents ebca371 + 30b1de5 commit 61c086c

File tree

21 files changed

+210
-69
lines changed

21 files changed

+210
-69
lines changed

app/code/Magento/Braintree/view/adminhtml/web/js/braintree.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ define([
145145
_initBraintree: function () {
146146
var self = this;
147147

148+
this.disableEventListeners();
149+
148150
self.braintree.setup(self.clientToken, 'custom', {
149151
id: self.selector,
150152
hostedFields: self.getHostedFields(),
@@ -154,6 +156,7 @@ define([
154156
*/
155157
onReady: function () {
156158
$('body').trigger('processStop');
159+
self.enableEventListeners();
157160
},
158161

159162
/**

app/code/Magento/Catalog/Model/Product/Link/SaveHandler.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,20 @@ class SaveHandler
3030
*/
3131
private $linkResource;
3232

33-
/**
34-
* @var linkTypeProvider
35-
*/
36-
private $linkTypeProvider;
37-
3833
/**
3934
* SaveHandler constructor.
4035
* @param MetadataPool $metadataPool
4136
* @param Link $linkResource
4237
* @param ProductLinkRepositoryInterface $productLinkRepository
43-
* @param \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
4438
*/
4539
public function __construct(
4640
MetadataPool $metadataPool,
4741
Link $linkResource,
48-
ProductLinkRepositoryInterface $productLinkRepository,
49-
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
42+
ProductLinkRepositoryInterface $productLinkRepository
5043
) {
5144
$this->metadataPool = $metadataPool;
5245
$this->linkResource = $linkResource;
5346
$this->productLinkRepository = $productLinkRepository;
54-
$this->linkTypeProvider = $linkTypeProvider;
5547
}
5648

5749
/**

app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,7 @@ public function getAttributeRawValue($entityId, $attribute, $store)
568568
}
569569

570570
if (is_array($attributesData) && sizeof($attributesData) == 1) {
571-
$_data = each($attributesData);
572-
$attributesData = $_data[1];
571+
$attributesData = array_shift($attributesData);
573572
}
574573

575574
return $attributesData === false ? false : $attributesData;

app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,21 @@ protected function _renderFiltersBefore()
366366
'search_result.'. TemporaryStorage::FIELD_SCORE . ' ' . $this->relevanceOrderDirection
367367
);
368368
}
369+
return parent::_renderFiltersBefore();
370+
}
369371

372+
/**
373+
* @inheritdoc
374+
*/
375+
protected function _beforeLoad()
376+
{
370377
/*
371378
* This order is required to force search results be the same
372379
* for the same requests and products with the same relevance
373380
* NOTE: this does not replace existing orders but ADDs one more
374381
*/
375382
$this->setOrder('entity_id');
376-
377-
return parent::_renderFiltersBefore();
383+
return parent::_beforeLoad();
378384
}
379385

380386
/**

app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ public function joinTable($table, $bind, $fields = null, $cond = null, $joinType
803803
{
804804
$tableAlias = null;
805805
if (is_array($table)) {
806-
list($tableAlias, $tableName) = each($table);
806+
list($tableAlias, $tableName) = [key($table), current($table)];
807807
} else {
808808
$tableName = $table;
809809
}

app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Sales\Api\Data\ShipmentTrackSearchResultInterfaceFactory;
1515
use Magento\Sales\Api\ShipmentTrackRepositoryInterface;
1616
use Magento\Sales\Model\Spi\ShipmentTrackResourceInterface;
17+
use Psr\Log\LoggerInterface;
1718

1819
class TrackRepository implements ShipmentTrackRepositoryInterface
1920
{
@@ -37,23 +38,30 @@ class TrackRepository implements ShipmentTrackRepositoryInterface
3738
*/
3839
private $collectionProcessor;
3940

41+
/**
42+
* @var LoggerInterface
43+
*/
44+
private $logger;
45+
4046
/**
4147
* @param ShipmentTrackResourceInterface $trackResource
4248
* @param ShipmentTrackInterfaceFactory $trackFactory
4349
* @param ShipmentTrackSearchResultInterfaceFactory $searchResultFactory
4450
* @param CollectionProcessorInterface $collectionProcessor
51+
* @param LoggerInterface|null $logger
4552
*/
4653
public function __construct(
4754
ShipmentTrackResourceInterface $trackResource,
4855
ShipmentTrackInterfaceFactory $trackFactory,
4956
ShipmentTrackSearchResultInterfaceFactory $searchResultFactory,
50-
CollectionProcessorInterface $collectionProcessor
57+
CollectionProcessorInterface $collectionProcessor,
58+
LoggerInterface $logger = null
5159
) {
52-
5360
$this->trackResource = $trackResource;
5461
$this->trackFactory = $trackFactory;
5562
$this->searchResultFactory = $searchResultFactory;
5663
$this->collectionProcessor = $collectionProcessor;
64+
$this->logger = $logger ?: \Magento\Framework\App\ObjectManager::getInstance()->get(LoggerInterface::class);
5765
}
5866

5967
/**
@@ -64,6 +72,7 @@ public function getList(SearchCriteriaInterface $searchCriteria)
6472
$searchResult = $this->searchResultFactory->create();
6573
$this->collectionProcessor->process($searchCriteria, $searchResult);
6674
$searchResult->setSearchCriteria($searchCriteria);
75+
6776
return $searchResult;
6877
}
6978

@@ -74,6 +83,7 @@ public function get($id)
7483
{
7584
$entity = $this->trackFactory->create();
7685
$this->trackResource->load($entity, $id);
86+
7787
return $entity;
7888
}
7989

@@ -85,8 +95,10 @@ public function delete(ShipmentTrackInterface $entity)
8595
try {
8696
$this->trackResource->delete($entity);
8797
} catch (\Exception $e) {
98+
$this->logger->error($e->getMessage());
8899
throw new CouldNotDeleteException(__('Could not delete the shipment tracking.'), $e);
89100
}
101+
90102
return true;
91103
}
92104

@@ -98,8 +110,10 @@ public function save(ShipmentTrackInterface $entity)
98110
try {
99111
$this->trackResource->save($entity);
100112
} catch (\Exception $e) {
113+
$this->logger->error($e->getMessage());
101114
throw new CouldNotSaveException(__('Could not save the shipment tracking.'), $e);
102115
}
116+
103117
return $entity;
104118
}
105119

@@ -109,6 +123,7 @@ public function save(ShipmentTrackInterface $entity)
109123
public function deleteById($id)
110124
{
111125
$entity = $this->get($id);
126+
112127
return $this->delete($entity);
113128
}
114129
}

app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Track.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Sales\Model\ResourceModel\Order\Shipment;
77

8+
use Magento\Framework\Exception\LocalizedException;
89
use Magento\Sales\Model\ResourceModel\EntityAbstract as SalesResource;
910
use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot;
1011
use Magento\Sales\Model\Spi\ShipmentTrackResourceInterface;
@@ -74,7 +75,7 @@ protected function _construct()
7475
*
7576
* @param \Magento\Framework\Model\AbstractModel $object
7677
* @return $this
77-
* @throws \Magento\Framework\Exception\LocalizedException
78+
* @throws LocalizedException
7879
*/
7980
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
8081
{
@@ -86,11 +87,16 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
8687
parent::_beforeSave($object);
8788
$errors = $this->validator->validate($object);
8889
if (!empty($errors)) {
89-
throw new \Magento\Framework\Exception\LocalizedException(
90+
throw new LocalizedException(
9091
__("Cannot save track:\n%1", implode("\n", $errors))
9192
);
9293
}
9394

95+
if ($object->getShipment()->getOrder()->getId() != $object->getOrderId()) {
96+
$errorMessage = 'Shipment with requested ID %1 doesn\'t correspond with Order with requested ID %2.';
97+
throw new LocalizedException(__($errorMessage, $object->getParentId(), $object->getOrderId()));
98+
}
99+
94100
return $this;
95101
}
96102
}

app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/TrackTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ protected function setUp()
8989
*/
9090
public function testSave()
9191
{
92+
$shipmentMock = $this->createMock(\Magento\Sales\Model\Order\Shipment::class);
93+
$orderMock = $this->createMock(\Magento\Sales\Model\Order::class);
9294
$this->entitySnapshotMock->expects($this->once())
9395
->method('isModified')
9496
->with($this->trackModelMock)
@@ -98,6 +100,8 @@ public function testSave()
98100
->with($this->equalTo($this->trackModelMock))
99101
->will($this->returnValue([]));
100102
$this->trackModelMock->expects($this->any())->method('getData')->willReturn([]);
103+
$this->trackModelMock->expects($this->atLeastOnce())->method('getShipment')->willReturn($shipmentMock);
104+
$shipmentMock->expects($this->atLeastOnce())->method('getOrder')->willReturn($orderMock);
101105
$this->trackResource->save($this->trackModelMock);
102106
$this->assertTrue(true);
103107
}

app/code/Magento/Sales/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,3 +803,4 @@ Created,Created
803803
"PDF Shipments","PDF Shipments"
804804
"PDF Creditmemos","PDF Creditmemos"
805805
Refunds,Refunds
806+
"Shipment with requested ID %1 doesn't correspond with Order with requested ID %2.","Shipment with requested ID %1 doesn't correspond with Order with requested ID %2."

app/code/Magento/Sales/view/adminhtml/templates/order/create/billing/method/form.phtml

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,60 @@
66

77
?>
88
<?php if ($block->hasMethods()) : ?>
9-
<div id="order-billing_method_form">
10-
<dl class="admin__payment-methods">
11-
<?php
12-
$_methods = $block->getMethods();
13-
$_methodsCount = count($_methods);
14-
$_counter = 0;
15-
?>
16-
<?php foreach ($_methods as $_method) :
17-
$_code = $_method->getCode();
18-
$_counter++;
19-
?>
20-
<dt class="admin__field-option">
21-
<?php if ($_methodsCount > 1) : ?>
22-
<input id="p_method_<?= $block->escapeHtml($_code); ?>"
23-
value="<?= $block->escapeHtml($_code); ?>"
24-
type="radio" name="payment[method]"
25-
title="<?= $block->escapeHtml($_method->getTitle()); ?>"
26-
onclick="payment.switchMethod('<?= $block->escapeHtml($_code); ?>')"
27-
<?php if ($block->getSelectedMethodCode() == $_code) : ?>
28-
checked="checked"
9+
<div id="order-billing_method_form">
10+
<dl class="admin__payment-methods">
11+
<?php
12+
$_methods = $block->getMethods();
13+
$_methodsCount = count($_methods);
14+
$_counter = 0;
15+
$currentSelectedMethod = $block->getSelectedMethodCode();
16+
?>
17+
<?php foreach ($_methods as $_method) :
18+
$_code = $_method->getCode();
19+
$_counter++;
20+
?>
21+
<dt class="admin__field-option">
22+
<?php if ($_methodsCount > 1) : ?>
23+
<input id="p_method_<?= $block->escapeHtml($_code); ?>"
24+
value="<?= $block->escapeHtml($_code); ?>"
25+
type="radio" name="payment[method]"
26+
title="<?= $block->escapeHtml($_method->getTitle()); ?>"
27+
onclick="payment.switchMethod('<?= $block->escapeHtml($_code); ?>')"
28+
<?php if ($block->getSelectedMethodCode() == $_code) : ?>
29+
checked="checked"
30+
<?php endif; ?>
31+
<?php $className = ($_counter == $_methodsCount) ? ' validate-one-required-by-name' : ''; ?>
32+
class="admin__control-radio<?= $block->escapeHtml($className); ?>"/>
33+
<?php else : ?>
34+
<span class="no-display">
35+
<input id="p_method_<?= $block->escapeHtml($_code); ?>"
36+
value="<?= $block->escapeHtml($_code); ?>"
37+
type="radio"
38+
name="payment[method]" class="admin__control-radio"
39+
checked="checked"/>
40+
</span>
2941
<?php endif; ?>
30-
<?php $className = ($_counter == $_methodsCount) ? ' validate-one-required-by-name' : ''; ?>
31-
class="admin__control-radio<?= $block->escapeHtml($className); ?>"/>
32-
<?php else :?>
33-
<span class="no-display">
34-
<input id="p_method_<?= $block->escapeHtml($_code); ?>"
35-
value="<?= $block->escapeHtml($_code); ?>"
36-
type="radio"
37-
name="payment[method]" class="admin__control-radio"
38-
checked="checked"/>
39-
</span>
40-
<?php endif;?>
4142

42-
<label class="admin__field-label"
43-
for="p_method_<?= $block->escapeHtml($_code); ?>"><?= $block->escapeHtml($_method->getTitle()) ?>
44-
</label>
45-
</dt>
46-
<dd class="admin__payment-method-wrapper">
47-
<?= /* @noEscape */ $block->getChildHtml('payment.method.' . $_code) ?>
48-
</dd>
49-
<?php endforeach; ?>
50-
</dl>
51-
</div>
43+
<label class="admin__field-label" for="p_method_<?= $block->escapeHtml($_code); ?>">
44+
<?= $block->escapeHtml($_method->getTitle()) ?>
45+
</label>
46+
</dt>
47+
<dd class="admin__payment-method-wrapper">
48+
<?= /* @noEscape */ $block->getChildHtml('payment.method.' . $_code) ?>
49+
</dd>
50+
<?php endforeach; ?>
51+
</dl>
52+
</div>
5253
<script>
5354
require([
5455
'mage/apply/main',
5556
'Magento_Sales/order/create/form'
5657
], function(mage) {
5758
mage.apply();
5859
<?php if ($_methodsCount != 1) : ?>
59-
order.setPaymentMethod('<?= $block->escapeHtml($block->getSelectedMethodCode()); ?>');
60+
order.setPaymentMethod('<?= $block->escapeHtml($currentSelectedMethod); ?>');
61+
<?php else : ?>
62+
payment.switchMethod('<?= $block->escapeHtml($currentSelectedMethod); ?>');
6063
<?php endif; ?>
6164
});
6265
</script>

0 commit comments

Comments
 (0)