Skip to content

Commit f83bb6b

Browse files
committed
Merge branch '2.2-develop' of https://github.com/magento/magento2ce into MAGETWO-88504
2 parents 1d23a21 + 116c2c3 commit f83bb6b

File tree

8 files changed

+225
-13
lines changed

8 files changed

+225
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The members of this team have been recognized for their outstanding commitment t
3535
</a>
3636

3737
<h3>Top Contributors</h3>
38-
Magento team thanks for any contribution that can improve our code base, documentation or increase test coverage. We always recognize our most active members, your contributions are the foundation of the Magento open source platform.
38+
Magento is thankful for any contribution that can improve our code base, documentation or increase test coverage. We always recognize our most active members, as their contributions are the foundation of the Magento Open Source platform.
3939
<a href="https://magento.com/magento-contributors">
4040
<img src="https://raw.githubusercontent.com/wiki/magento/magento2/images/contributors.png"/>
4141
</a>

app/code/Magento/CheckoutAgreements/Block/Adminhtml/Agreement/Grid.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,42 @@
55
*/
66
namespace Magento\CheckoutAgreements\Block\Adminhtml\Agreement;
77

8+
use Magento\Framework\App\ObjectManager;
9+
use Magento\CheckoutAgreements\Model\ResourceModel\Agreement\Grid\CollectionFactory as GridCollectionFactory;
10+
811
class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
912
{
1013
/**
1114
* @var \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\CollectionFactory
15+
* @deprecated
1216
*/
1317
protected $_collectionFactory;
1418

19+
/**
20+
* @param GridCollectionFactory
21+
*/
22+
private $gridCollectionFactory;
23+
1524
/**
1625
* @param \Magento\Backend\Block\Template\Context $context
1726
* @param \Magento\Backend\Helper\Data $backendHelper
1827
* @param \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\CollectionFactory $collectionFactory
1928
* @param array $data
29+
* @param GridCollectionFactory $gridColFactory
2030
* @codeCoverageIgnore
2131
*/
2232
public function __construct(
2333
\Magento\Backend\Block\Template\Context $context,
2434
\Magento\Backend\Helper\Data $backendHelper,
2535
\Magento\CheckoutAgreements\Model\ResourceModel\Agreement\CollectionFactory $collectionFactory,
26-
array $data = []
36+
array $data = [],
37+
GridCollectionFactory $gridColFactory = null
2738
) {
39+
2840
$this->_collectionFactory = $collectionFactory;
41+
$this->gridCollectionFactory = $gridColFactory
42+
? : ObjectManager::getInstance()->get(GridCollectionFactory::class);
43+
2944
parent::__construct($context, $backendHelper, $data);
3045
}
3146

@@ -47,7 +62,7 @@ protected function _construct()
4762
*/
4863
protected function _prepareCollection()
4964
{
50-
$this->setCollection($this->_collectionFactory->create());
65+
$this->setCollection($this->gridCollectionFactory->create());
5166
return parent::_prepareCollection();
5267
}
5368

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CheckoutAgreements\Model\ResourceModel\Agreement\Grid;
8+
9+
/**
10+
* CheckoutAgreement Grid Collection
11+
*/
12+
class Collection extends \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\Collection
13+
{
14+
15+
/**
16+
* {@inheritdoc}
17+
*/
18+
public function load($printQuery = false, $logQuery = false)
19+
{
20+
if ($this->isLoaded()) {
21+
return $this;
22+
}
23+
24+
parent::load($printQuery, $logQuery);
25+
26+
$this->addStoresToResult();
27+
28+
return $this;
29+
}
30+
31+
/**
32+
* @return void
33+
*/
34+
private function addStoresToResult()
35+
{
36+
$stores = $this->getStoresForAgreements();
37+
38+
if (!empty($stores)) {
39+
$storesByAgreementId = [];
40+
41+
foreach ($stores as $storeData) {
42+
$storesByAgreementId[$storeData['agreement_id']][] = $storeData['store_id'];
43+
}
44+
45+
foreach ($this as $item) {
46+
$agreementId = $item->getData('agreement_id');
47+
48+
if (!isset($storesByAgreementId[$agreementId])) {
49+
continue;
50+
}
51+
52+
$item->setData('stores', $storesByAgreementId[$agreementId]);
53+
}
54+
}
55+
}
56+
57+
/**
58+
* @return array
59+
*/
60+
private function getStoresForAgreements()
61+
{
62+
$agreementId = $this->getColumnValues('agreement_id');
63+
64+
if (!empty($agreementId)) {
65+
$select = $this->getConnection()->select()->from(
66+
['agreement_store' => 'checkout_agreement_store']
67+
)->where(
68+
'agreement_store.agreement_id IN (?)',
69+
$agreementId
70+
);
71+
72+
return $this->getConnection()->fetchAll($select);
73+
}
74+
75+
return [];
76+
}
77+
}

app/code/Magento/Customer/Block/Account/Navigation.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public function getLinks()
4646
*/
4747
private function compare(SortLinkInterface $firstLink, SortLinkInterface $secondLink)
4848
{
49-
return ($firstLink->getSortOrder() < $secondLink->getSortOrder());
49+
if ($firstLink->getSortOrder() == $secondLink->getSortOrder()) {
50+
return 0;
51+
}
52+
53+
return ($firstLink->getSortOrder() < $secondLink->getSortOrder()) ? 1 : -1;
5054
}
5155
}

app/code/Magento/Customer/Model/EmailNotification.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,9 @@ private function getWebsiteStoreId($customer, $defaultStoreId = null)
314314
*/
315315
public function passwordReminder(CustomerInterface $customer)
316316
{
317-
$storeId = $this->getWebsiteStoreId($customer);
317+
$storeId = $customer->getStoreId();
318318
if (!$storeId) {
319-
$storeId = $this->storeManager->getStore()->getId();
319+
$storeId = $this->getWebsiteStoreId($customer);
320320
}
321321

322322
$customerEmailData = $this->getFullCustomerObject($customer);

app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php

Lines changed: 121 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,16 @@ public function sendNotificationEmailsDataProvider()
312312
public function testPasswordReminder()
313313
{
314314
$customerId = 1;
315+
$customerWebsiteId = 1;
315316
$customerStoreId = 2;
316317
$customerEmail = 'email@email.com';
317318
$customerData = ['key' => 'value'];
318319
$customerName = 'Customer Name';
319320
$templateIdentifier = 'Template Identifier';
320321
$sender = 'Sender';
321322
$senderValues = ['name' => $sender, 'email' => $sender];
322-
323+
$storeIds = [1, 2];
324+
323325
$this->senderResolverMock
324326
->expects($this->once())
325327
->method('resolve')
@@ -328,6 +330,9 @@ public function testPasswordReminder()
328330

329331
/** @var CustomerInterface | \PHPUnit_Framework_MockObject_MockObject $customer */
330332
$customer = $this->createMock(CustomerInterface::class);
333+
$customer->expects($this->any())
334+
->method('getWebsiteId')
335+
->willReturn($customerWebsiteId);
331336
$customer->expects($this->any())
332337
->method('getStoreId')
333338
->willReturn($customerStoreId);
@@ -346,11 +351,16 @@ public function testPasswordReminder()
346351
->method('getStore')
347352
->willReturn($this->storeMock);
348353

349-
$this->storeManagerMock->expects($this->at(1))
350-
->method('getStore')
351-
->with($customerStoreId)
352-
->willReturn($this->storeMock);
354+
$websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getStoreIds']);
355+
$websiteMock->expects($this->any())
356+
->method('getStoreIds')
357+
->willReturn($storeIds);
353358

359+
$this->storeManagerMock->expects($this->any())
360+
->method('getWebsite')
361+
->with($customerWebsiteId)
362+
->willReturn($websiteMock);
363+
354364
$this->customerRegistryMock->expects($this->once())
355365
->method('retrieveSecureData')
356366
->with($customerId)
@@ -396,6 +406,112 @@ public function testPasswordReminder()
396406
$this->model->passwordReminder($customer);
397407
}
398408

409+
/**
410+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
411+
*/
412+
public function testPasswordReminderCustomerWithoutStoreId()
413+
{
414+
$customerId = 1;
415+
$customerWebsiteId = 1;
416+
$customerStoreId = null;
417+
$customerEmail = 'email@email.com';
418+
$customerData = ['key' => 'value'];
419+
$customerName = 'Customer Name';
420+
$templateIdentifier = 'Template Identifier';
421+
$sender = 'Sender';
422+
$senderValues = ['name' => $sender, 'email' => $sender];
423+
$storeIds = [1, 2];
424+
$defaultStoreId = reset($storeIds);
425+
426+
$this->senderResolverMock
427+
->expects($this->once())
428+
->method('resolve')
429+
->with($sender, $defaultStoreId)
430+
->willReturn($senderValues);
431+
432+
/** @var CustomerInterface | \PHPUnit_Framework_MockObject_MockObject $customer */
433+
$customer = $this->createMock(CustomerInterface::class);
434+
$customer->expects($this->any())
435+
->method('getWebsiteId')
436+
->willReturn($customerWebsiteId);
437+
$customer->expects($this->any())
438+
->method('getStoreId')
439+
->willReturn($customerStoreId);
440+
$customer->expects($this->any())
441+
->method('getId')
442+
->willReturn($customerId);
443+
$customer->expects($this->any())
444+
->method('getEmail')
445+
->willReturn($customerEmail);
446+
447+
$this->storeMock->expects($this->any())
448+
->method('getId')
449+
->willReturn($defaultStoreId);
450+
451+
$this->storeManagerMock->expects($this->at(0))
452+
->method('getStore')
453+
->willReturn($this->storeMock);
454+
455+
$this->storeManagerMock->expects($this->at(1))
456+
->method('getStore')
457+
->with($defaultStoreId)
458+
->willReturn($this->storeMock);
459+
460+
$websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getStoreIds']);
461+
$websiteMock->expects($this->any())
462+
->method('getStoreIds')
463+
->willReturn($storeIds);
464+
465+
$this->storeManagerMock->expects($this->any())
466+
->method('getWebsite')
467+
->with($customerWebsiteId)
468+
->willReturn($websiteMock);
469+
470+
$this->customerRegistryMock->expects($this->once())
471+
->method('retrieveSecureData')
472+
->with($customerId)
473+
->willReturn($this->customerSecureMock);
474+
475+
$this->dataProcessorMock->expects($this->once())
476+
->method('buildOutputDataArray')
477+
->with($customer, CustomerInterface::class)
478+
->willReturn($customerData);
479+
480+
$this->customerViewHelperMock->expects($this->any())
481+
->method('getCustomerName')
482+
->with($customer)
483+
->willReturn($customerName);
484+
485+
$this->customerSecureMock->expects($this->once())
486+
->method('addData')
487+
->with($customerData)
488+
->willReturnSelf();
489+
$this->customerSecureMock->expects($this->once())
490+
->method('setData')
491+
->with('name', $customerName)
492+
->willReturnSelf();
493+
494+
$this->scopeConfigMock->expects($this->at(0))
495+
->method('getValue')
496+
->with(EmailNotification::XML_PATH_REMIND_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $defaultStoreId)
497+
->willReturn($templateIdentifier);
498+
$this->scopeConfigMock->expects($this->at(1))
499+
->method('getValue')
500+
->with(EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $defaultStoreId)
501+
->willReturn($sender);
502+
503+
$this->mockDefaultTransportBuilder(
504+
$templateIdentifier,
505+
$defaultStoreId,
506+
$senderValues,
507+
$customerEmail,
508+
$customerName,
509+
['customer' => $this->customerSecureMock, 'store' => $this->storeMock]
510+
);
511+
512+
$this->model->passwordReminder($customer);
513+
}
514+
399515
/**
400516
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
401517
*/

app/code/Magento/Directory/Model/Currency.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function convert($price, $toCurrency = null)
225225
if ($toCurrency === null) {
226226
return $price;
227227
} elseif ($rate = $this->getRate($toCurrency)) {
228-
return $price * $rate;
228+
return floatval($price) * floatval($rate);
229229
}
230230

231231
throw new \Exception(__(

app/code/Magento/Sales/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@
687687
<item name="shipping_address" xsi:type="object">ShippingAddressAggregator</item>
688688
<item name="shipping_information" xsi:type="string">sales_order.shipping_description</item>
689689
<item name="subtotal" xsi:type="string">sales_invoice.base_subtotal</item>
690-
<item name="shipping_and_handling" xsi:type="string">sales_order.base_shipping_amount</item>
690+
<item name="shipping_and_handling" xsi:type="string">sales_invoice.base_shipping_amount</item>
691691
<item name="base_grand_total" xsi:type="string">sales_invoice.base_grand_total</item>
692692
<item name="grand_total" xsi:type="string">sales_invoice.grand_total</item>
693693
<item name="created_at" xsi:type="string">sales_invoice.created_at</item>

0 commit comments

Comments
 (0)