Skip to content

Commit 5184c06

Browse files
authored
Merge pull request #9380 from adobe-commerce-tier-4/Tier4-Kings-PR-11-22-2024
[Support Tier-4-Kings glo02433] 11.22.2024 Regular delivery of bugfixes and improvements
2 parents 7ead0dc + a87d9ec commit 5184c06

File tree

22 files changed

+562
-169
lines changed

22 files changed

+562
-169
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -297,14 +297,14 @@ private function sendEmailTemplate(
297297
$storeId
298298
);
299299

300+
$this->emulation->startEnvironmentEmulation($storeId, \Magento\Framework\App\Area::AREA_FRONTEND);
300301
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
301302
->setTemplateOptions(['area' => 'frontend', 'store' => $storeId])
302303
->setTemplateVars($templateParams)
303304
->setFrom($from)
304305
->addTo($email, $this->customerViewHelper->getCustomerName($customer))
305306
->getTransport();
306307

307-
$this->emulation->startEnvironmentEmulation($storeId, \Magento\Framework\App\Area::AREA_FRONTEND);
308308
$transport->sendMessage();
309309
$this->emulation->stopEnvironmentEmulation();
310310
}

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -423,6 +423,17 @@ public static function getAllOptionsDataProvider()
423423
['value' => '16', 'label' => 'black'],
424424
['value' => '17', 'label' => 'white']
425425
]
426+
],
427+
[
428+
true,
429+
true,
430+
[['value' => '16', 'label' => 'default sv black'], ['value' => '17', 'label' => 'default sv white']],
431+
[['value' => '16', 'label' => 'black'], ['value' => '17', 'label' => 'white']],
432+
[
433+
['label' => ' ', 'value' => ''],
434+
['value' => '16', 'label' => 'black'],
435+
['value' => '17', 'label' => 'white']
436+
]
426437
]
427438
];
428439
}

app/code/Magento/Quote/Model/CustomerManagement.php

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -10,6 +10,7 @@
1010
use Magento\Customer\Api\AccountManagementInterface as AccountManagement;
1111
use Magento\Customer\Api\AddressRepositoryInterface as CustomerAddressRepository;
1212
use Magento\Customer\Api\CustomerRepositoryInterface as CustomerRepository;
13+
use Magento\Customer\Api\Data\AddressInterfaceFactory;
1314
use Magento\Customer\Model\AddressFactory;
1415
use Magento\Framework\App\ObjectManager;
1516
use Magento\Framework\Validator\Exception as ValidatorException;
@@ -46,24 +47,32 @@ class CustomerManagement
4647
*/
4748
private $addressFactory;
4849

50+
/**
51+
* @var AddressInterfaceFactory
52+
*/
53+
private $customerAddressFactory;
54+
4955
/**
5056
* CustomerManagement constructor.
5157
* @param CustomerRepository $customerRepository
5258
* @param CustomerAddressRepository $customerAddressRepository
5359
* @param AccountManagement $accountManagement
60+
* @param AddressInterfaceFactory $customerAddressFactory
5461
* @param ValidatorFactory|null $validatorFactory
5562
* @param AddressFactory|null $addressFactory
5663
*/
5764
public function __construct(
5865
CustomerRepository $customerRepository,
5966
CustomerAddressRepository $customerAddressRepository,
6067
AccountManagement $accountManagement,
68+
AddressInterfaceFactory $customerAddressFactory,
6169
ValidatorFactory $validatorFactory = null,
6270
AddressFactory $addressFactory = null
6371
) {
6472
$this->customerRepository = $customerRepository;
6573
$this->customerAddressRepository = $customerAddressRepository;
6674
$this->accountManagement = $accountManagement;
75+
$this->customerAddressFactory = $customerAddressFactory;
6776
$this->validatorFactory = $validatorFactory ?: ObjectManager::getInstance()
6877
->get(ValidatorFactory::class);
6978
$this->addressFactory = $addressFactory ?: ObjectManager::getInstance()
@@ -150,18 +159,29 @@ public function validateAddresses(QuoteEntity $quote)
150159
$quote->getShippingAddress()->getCustomerAddressId()
151160
);
152161
}
153-
if (!empty($addresses)) {
154-
foreach ($addresses as $address) {
155-
$validator = $this->validatorFactory->createValidator('customer_address', 'save');
156-
$addressModel = $this->addressFactory->create();
157-
$addressModel->updateData($address);
158-
if (!$validator->isValid($addressModel)) {
159-
throw new ValidatorException(
160-
null,
161-
null,
162-
$validator->getMessages()
163-
);
164-
}
162+
if (empty($addresses) && $quote->getCustomerIsGuest()) {
163+
$billingAddress = $quote->getBillingAddress();
164+
$customerAddress = $this->customerAddressFactory->create();
165+
$customerAddress->setFirstname($billingAddress->getFirstname());
166+
$customerAddress->setLastname($billingAddress->getLastname());
167+
$customerAddress->setStreet($billingAddress->getStreet());
168+
$customerAddress->setCity($billingAddress->getCity());
169+
$customerAddress->setPostcode($billingAddress->getPostcode());
170+
$customerAddress->setTelephone($billingAddress->getTelephone());
171+
$customerAddress->setCountryId($billingAddress->getCountryId());
172+
$customerAddress->setCustomAttributes($billingAddress->getCustomAttributes());
173+
$addresses[] = $customerAddress;
174+
}
175+
foreach ($addresses as $address) {
176+
$validator = $this->validatorFactory->createValidator('customer_address', 'save');
177+
$addressModel = $this->addressFactory->create();
178+
$addressModel->updateData($address);
179+
if (!$validator->isValid($addressModel)) {
180+
throw new ValidatorException(
181+
null,
182+
null,
183+
$validator->getMessages()
184+
);
165185
}
166186
}
167187
}

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -565,10 +565,10 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
565565
if (!$quote->getCustomerIsGuest()) {
566566
if ($quote->getCustomerId()) {
567567
$this->_prepareCustomerQuote($quote);
568-
$this->customerManagement->validateAddresses($quote);
569568
}
570569
$this->customerManagement->populateCustomerInfo($quote);
571570
}
571+
$this->customerManagement->validateAddresses($quote);
572572
$addresses = [];
573573
$quote->reserveOrderId();
574574
if ($quote->isVirtual()) {

app/code/Magento/Quote/Test/Unit/Model/CustomerManagementTest.php

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -11,9 +11,11 @@
1111
use Magento\Customer\Api\AddressRepositoryInterface;
1212
use Magento\Customer\Api\CustomerRepositoryInterface;
1313
use Magento\Customer\Api\Data\AddressInterface;
14+
use Magento\Customer\Api\Data\AddressInterfaceFactory;
1415
use Magento\Customer\Api\Data\CustomerInterface;
1516
use Magento\Customer\Model\AddressFactory;
1617
use Magento\Framework\Validator;
18+
use Magento\Framework\Validator\Exception as ValidatorException;
1719
use Magento\Framework\Validator\Factory;
1820
use Magento\Quote\Model\CustomerManagement;
1921
use Magento\Quote\Model\Quote;
@@ -76,6 +78,11 @@ class CustomerManagementTest extends TestCase
7678
*/
7779
private $addressFactoryMock;
7880

81+
/**
82+
* @var MockObject
83+
*/
84+
private $customerAddressFactoryMock;
85+
7986
protected function setUp(): void
8087
{
8188
$this->customerRepositoryMock = $this->getMockForAbstractClass(
@@ -107,7 +114,8 @@ protected function setUp(): void
107114
);
108115
$this->quoteMock = $this->getMockBuilder(Quote::class)
109116
->addMethods(['getPasswordHash'])
110-
->onlyMethods(['getId', 'getCustomer', 'getBillingAddress', 'getShippingAddress', 'setCustomer'])
117+
->onlyMethods(['getId', 'getCustomer', 'getBillingAddress', 'getShippingAddress', 'setCustomer',
118+
'getCustomerIsGuest'])
111119
->disableOriginalConstructor()
112120
->getMock();
113121
$this->quoteAddressMock = $this->createMock(Address::class);
@@ -136,10 +144,20 @@ protected function setUp(): void
136144
$this->validatorFactoryMock = $this->getMockBuilder(Factory::class)
137145
->disableOriginalConstructor()
138146
->getMock();
147+
$this->customerAddressFactoryMock = $this->getMockForAbstractClass(
148+
AddressInterfaceFactory::class,
149+
[],
150+
'',
151+
false,
152+
true,
153+
true,
154+
['create']
155+
);
139156
$this->customerManagement = new CustomerManagement(
140157
$this->customerRepositoryMock,
141158
$this->customerAddressRepositoryMock,
142159
$this->accountManagementMock,
160+
$this->customerAddressFactoryMock,
143161
$this->validatorFactoryMock,
144162
$this->addressFactoryMock
145163
);
@@ -249,19 +267,35 @@ public function testValidateAddresses()
249267

250268
public function testValidateAddressesNotSavedInAddressBook()
251269
{
270+
$this->expectException(ValidatorException::class);
271+
$this->quoteMock->method('getCustomerIsGuest')->willReturn(true);
272+
$this->quoteAddressMock->method('getStreet')->willReturn(['test']);
273+
$this->quoteAddressMock->method('getCustomAttributes')->willReturn(['test']);
274+
$this->customerAddressFactoryMock->method('create')
275+
->willReturn($this->customerAddressMock);
276+
$addressMock = $this->getMockBuilder(Address::class)
277+
->disableOriginalConstructor()
278+
->getMock();
279+
$this->addressFactoryMock->expects($this->exactly(1))->method('create')->willReturn($addressMock);
252280
$this->quoteMock
253-
->expects($this->once())
281+
->expects($this->atMost(2))
254282
->method('getBillingAddress')
255283
->willReturn($this->quoteAddressMock);
256284
$this->quoteMock
257285
->expects($this->once())
258286
->method('getShippingAddress')
259287
->willReturn($this->quoteAddressMock);
260288
$this->quoteAddressMock->expects($this->any())->method('getCustomerAddressId')->willReturn(null);
289+
$validatorMock = $this->getMockBuilder(Validator::class)
290+
->disableOriginalConstructor()
291+
->getMock();
261292
$this->validatorFactoryMock
262-
->expects($this->never())
293+
->expects($this->exactly(1))
263294
->method('createValidator')
264-
->with('customer_address', 'save', null);
295+
->with('customer_address', 'save', null)
296+
->willReturn($validatorMock);
297+
$validatorMock->expects($this->exactly(1))->method('isValid')->with($addressMock)->willReturn(false);
298+
$validatorMock->expects($this->exactly(1))->method('getMessages')->willReturn([]);
265299
$this->customerManagement->validateAddresses($this->quoteMock);
266300
}
267301
}

app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Rule\Model\Condition\Product;
@@ -243,7 +243,7 @@ protected function _prepareValueOptions()
243243
} else {
244244
$addEmptyOption = true;
245245
}
246-
$selectOptions = $attributeObject->getSource()->getAllOptions($addEmptyOption);
246+
$selectOptions = $attributeObject->getSource()->getAllOptions($addEmptyOption, true);
247247
}
248248
}
249249

app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -360,7 +360,7 @@ public function testPrepareValueOptions(
360360
$attrObjectSourceMock
361361
->expects((null === $expectedAttrObjSourceAllOptionsParam) ? $this->never() : $this->once())
362362
->method('getAllOptions')
363-
->with($expectedAttrObjSourceAllOptionsParam)
363+
->with($expectedAttrObjSourceAllOptionsParam, true)
364364
->willReturn($attrObjectSourceAllOptionsValue);
365365

366366
$attributeObjectMock = $this->getMockBuilder(Attribute::class)

app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,15 +1376,26 @@
13761376

13771377
submit: function () {
13781378
var $editForm = jQuery('#edit_form'),
1379+
$submitButton = jQuery('#submit_order_top_button'),
13791380
beforeSubmitOrderEvent;
13801381

13811382
if ($editForm.valid()) {
1383+
$submitButton.prop('disabled', true);
1384+
13821385
$editForm.trigger('processStart');
13831386
beforeSubmitOrderEvent = jQuery.Event('beforeSubmitOrder');
13841387
$editForm.trigger(beforeSubmitOrderEvent);
1388+
13851389
if (beforeSubmitOrderEvent.result !== false) {
13861390
$editForm.trigger('submitOrder');
1391+
} else {
1392+
$submitButton.prop('disabled', false);
13871393
}
1394+
1395+
$editForm.on('submitOrderComplete', function () {
1396+
$submitButton.prop('disabled', false);
1397+
$editForm.trigger('processStop');
1398+
});
13881399
}
13891400
},
13901401

app/code/Magento/Search/Test/Mftf/Test/AdminNewSearchSynonymsFormResetTest.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
6-
*/
3+
/************************************************************************
4+
*
5+
* Copyright 2020 Adobe
6+
* All Rights Reserved.
7+
*
8+
* ************************************************************************
9+
*/
710
-->
811

912
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -39,7 +42,7 @@
3942
</actionGroup>
4043

4144
<click selector="{{AdminSearchSynonymsNewSection.resetButton}}" stepKey="clickResetButton"/>
42-
45+
<waitForPageLoad stepKey="waitForPageLoaded"/>
4346
<grabValueFrom selector="{{AdminSearchSynonymsNewSection.scope}}" stepKey="grabScopeValue"/>
4447
<assertEquals stepKey="assertScopeDefaultValue">
4548
<expectedResult type="string">0:0</expectedResult>
@@ -53,7 +56,7 @@
5356

5457
<grabValueFrom selector="{{AdminSearchSynonymsNewSection.merge}}" stepKey="grabMergeValue"/>
5558
<assertEquals stepKey="assertMergeDefaultValue">
56-
<expectedResult type="string">false</expectedResult>
59+
<expectedResult type="string">0</expectedResult>
5760
<actualResult type="string">$grabMergeValue</actualResult>
5861
</assertEquals>
5962
</test>

0 commit comments

Comments
 (0)