Skip to content

Commit 5351c27

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.3-develop latest changes
Accepted Community Pull Requests: - #24226: Remove redundant file (by @dshevtsov) - #24205: Resolve Some Fields in "Currency Setup" must have validate number issue24204 (by @edenduong) - #24195: fix lost the table prefix in setup (by @duhon) - #24174: "Admin Session Lifetime" should use JS validate (to optimize UI/UX) (by @edenduong) - #24163: Resolve Comment "Warning!" in "Allow Symlinks" should have red color like other notices (issue 24162) (by @edenduong) - #24176: Update AdvancedSearch ReadMe (by @diazwatson) - #24182: Resolve undefine variable in _createUserRole function (by @edenduong) - #24016: No alert when user "Apply empty Coupon Code" in create new order form (issue 24015) (by @edenduong) - #20577: #19230: [Forwardport] Can't Cancel Order (by @p-bystritsky) - #23621: Media gallery loaded twice (by @sidolov) Fixed GitHub Issues: - #24204: Some Fields in "Currency Setup" must have validate number (reported by @edenduong) has been fixed in #24205 by @edenduong in 2.3-develop branch Related commits: 1. b9646ce - #24162: Comment "Warning!" in "Allow Symlinks" should have red color like other notices (reported by @edenduong) has been fixed in #24163 by @edenduong in 2.3-develop branch Related commits: 1. 95b877c 2. e8e8882 3. 3d1b0c1 - #24015: No alert when user "Apply empty Coupon Code" in create new order form (reported by @edenduong) has been fixed in #24016 by @edenduong in 2.3-develop branch Related commits: 1. 866a154 2. 7c40321 - #19230: Can't Cancel Order (reported by @friendscottn) has been fixed in #20577 by @p-bystritsky in 2.3-develop branch Related commits: 1. 5a24c41 2. 44760ff 3. ae76c57 4. d8add8a 5. 2fd017a 6. 565d0b1
2 parents ad44545 + ba0952b commit 5351c27

File tree

19 files changed

+721
-8903
lines changed

19 files changed

+721
-8903
lines changed
Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,38 @@
1-
AdvancedSearch module introduces advanced search functionality and provides interfaces that allow to implement this functionality by 3rd party search engines
1+
# Magento_AdvancedSearch module
2+
The Magento_AdvancedSearch module introduces advanced search functionality and provides interfaces that allow third-party search engines to implement this functionality.
3+
4+
## Installation details
5+
6+
Before disabling or uninstalling this module, note that the following modules depends on this module:
7+
- Magento_Elasticsearch
8+
- Magento_Elasticsearch6
9+
10+
For information about module installation in Magento 2, see [Enable or disable modules](https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-subcommands-enable.html).
11+
12+
## Extensibility
13+
14+
Extension developers can interact with the Magento_AdvancedSearch module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html).
15+
16+
[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_AdvancedSearch module.
17+
18+
### Events
19+
20+
This module observes the following event:
21+
22+
- `catalogsearch_query_save_after` in the `Magento\AdvancedSearch\Model\Recommendations\SaveSearchQueryRelationsObserver` file.
23+
24+
For information about an event in Magento 2, see [Events and observers](http://devdocs.magento.com/guides/v2.3/extension-dev-guide/events-and-observers.html#events).
25+
26+
### Layouts
27+
28+
The module interacts with the following layout handles in the `view/adminhtml/layout` directory:
29+
30+
- `catalog_search_block`
31+
- `catalog_search_edit`
32+
- `catalog_search_relatedgrid`
33+
34+
The module interacts with the following layout handles in the `view/frontend/layout` directory:
35+
36+
- `catalogsearch_result_index`
37+
38+
For more information about layouts in Magento 2, see the [Layout documentation](https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-overview.html).

app/code/Magento/Backend/etc/adminhtml/system.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@
145145
<field id="allow_symlink" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
146146
<label>Allow Symlinks</label>
147147
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
148-
<comment>Warning! Enabling this feature is not recommended on production environments because it represents a potential security risk.</comment>
148+
<comment>
149+
<![CDATA[<strong style="color:red">Warning!</strong> Enabling this feature is not recommended on production environments because it represents a potential security risk.]]>
150+
</comment>
149151
</field>
150152
<field id="minify_html" translate="label comment" type="select" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
151153
<label>Minify Html</label>
@@ -435,7 +437,7 @@
435437
<label>Admin Session Lifetime (seconds)</label>
436438
<comment>Please enter at least 60 and at most 31536000 (one year).</comment>
437439
<backend_model>Magento\Backend\Model\Config\SessionLifetime\BackendModel</backend_model>
438-
<validate>validate-digits</validate>
440+
<validate>validate-digits validate-digits-range digits-range-60-31536000</validate>
439441
</field>
440442
</group>
441443
<group id="dashboard" translate="label" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ Debug,Debug
333333
"Add Block Names to Hints","Add Block Names to Hints"
334334
"Template Settings","Template Settings"
335335
"Allow Symlinks","Allow Symlinks"
336-
"Warning! Enabling this feature is not recommended on production environments because it represents a potential security risk.","Warning! Enabling this feature is not recommended on production environments because it represents a potential security risk."
336+
"<strong style=""color:red"">Warning!</strong> Enabling this feature is not recommended on production environments because it represents a potential security risk.","<strong style=""color:red"">Warning!</strong> Enabling this feature is not recommended on production environments because it represents a potential security risk."
337337
"Minify Html","Minify Html"
338338
"Minification is not applied in developer mode.","Minification is not applied in developer mode."
339339
"Translate Inline","Translate Inline"

app/code/Magento/Directory/etc/adminhtml/system.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
</field>
4444
<field id="timeout" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
4545
<label>Connection Timeout in Seconds</label>
46+
<validate>validate-zero-or-greater validate-number</validate>
4647
</field>
4748
</group>
4849
<group id="currencyconverterapi" translate="label" sortOrder="45" showInDefault="1" showInWebsite="0" showInStore="0">
@@ -54,6 +55,7 @@
5455
</field>
5556
<field id="timeout" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
5657
<label>Connection Timeout in Seconds</label>
58+
<validate>validate-zero-or-greater validate-number</validate>
5759
</field>
5860
</group>
5961
<group id="import" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Model\Order;
9+
10+
use Magento\Customer\Api\Data\CustomerInterface;
11+
use Magento\Framework\Event\ManagerInterface;
12+
use Magento\Sales\Api\Data\OrderInterface;
13+
use Magento\Sales\Api\OrderRepositoryInterface;
14+
15+
/**
16+
* Assign customer to order.
17+
*/
18+
class CustomerAssignment
19+
{
20+
/**
21+
* @var ManagerInterface
22+
*/
23+
private $eventManager;
24+
25+
/**
26+
* @var OrderRepositoryInterface
27+
*/
28+
private $orderRepository;
29+
30+
/**
31+
* CustomerAssignment constructor.
32+
*
33+
* @param ManagerInterface $eventManager
34+
* @param OrderRepositoryInterface $orderRepository
35+
*/
36+
public function __construct(
37+
ManagerInterface $eventManager,
38+
OrderRepositoryInterface $orderRepository
39+
) {
40+
$this->eventManager = $eventManager;
41+
$this->orderRepository = $orderRepository;
42+
}
43+
44+
/**
45+
* Assign customer to order.
46+
*
47+
* @param OrderInterface $order
48+
* @param CustomerInterface $customer
49+
*/
50+
public function execute(OrderInterface $order, CustomerInterface $customer): void
51+
{
52+
$order->setCustomerId($customer->getId())
53+
->setCustomerIsGuest(false)
54+
->setCustomerEmail($customer->getEmail())
55+
->setCustomerFirstname($customer->getFirstname())
56+
->setCustomerLastname($customer->getLastname())
57+
->setCustomerMiddlename($customer->getMiddlename())
58+
->setCustomerPrefix($customer->getPrefix())
59+
->setCustomerSuffix($customer->getSuffix())
60+
->setCustomerGroupId($customer->getGroupId());
61+
62+
$this->orderRepository->save($order);
63+
64+
$this->eventManager->dispatch(
65+
'sales_order_customer_assign_after',
66+
[
67+
'order' => $order,
68+
'customer' => $customer
69+
]
70+
);
71+
}
72+
}

app/code/Magento/Sales/Observer/AssignOrderToCustomerObserver.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Event\Observer;
1212
use Magento\Framework\Event\ObserverInterface;
1313
use Magento\Sales\Api\OrderRepositoryInterface;
14+
use Magento\Sales\Model\Order\CustomerAssignment;
1415

1516
/**
1617
* Assign order to customer created after issuing guest order.
@@ -23,11 +24,22 @@ class AssignOrderToCustomerObserver implements ObserverInterface
2324
private $orderRepository;
2425

2526
/**
27+
* @var CustomerAssignment
28+
*/
29+
private $assignmentService;
30+
31+
/**
32+
* AssignOrderToCustomerObserver constructor.
33+
*
2634
* @param OrderRepositoryInterface $orderRepository
35+
* @param CustomerAssignment $assignmentService
2736
*/
28-
public function __construct(OrderRepositoryInterface $orderRepository)
29-
{
37+
public function __construct(
38+
OrderRepositoryInterface $orderRepository,
39+
CustomerAssignment $assignmentService
40+
) {
3041
$this->orderRepository = $orderRepository;
42+
$this->assignmentService = $assignmentService;
3143
}
3244

3345
/**
@@ -43,18 +55,8 @@ public function execute(Observer $observer)
4355
if (array_key_exists('__sales_assign_order_id', $delegateData)) {
4456
$orderId = $delegateData['__sales_assign_order_id'];
4557
$order = $this->orderRepository->get($orderId);
46-
if (!$order->getCustomerId()) {
47-
//assign customer info to order after customer creation.
48-
$order->setCustomerId($customer->getId())
49-
->setCustomerIsGuest(0)
50-
->setCustomerEmail($customer->getEmail())
51-
->setCustomerFirstname($customer->getFirstname())
52-
->setCustomerLastname($customer->getLastname())
53-
->setCustomerMiddlename($customer->getMiddlename())
54-
->setCustomerPrefix($customer->getPrefix())
55-
->setCustomerSuffix($customer->getSuffix())
56-
->setCustomerGroupId($customer->getGroupId());
57-
$this->orderRepository->save($order);
58+
if (!$order->getCustomerId() && $customer->getId()) {
59+
$this->assignmentService->execute($order, $customer);
5860
}
5961
}
6062
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Test\Unit\Model\Order;
9+
10+
use Magento\Customer\Api\Data\CustomerInterface;
11+
use Magento\Framework\Event\ManagerInterface;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13+
use Magento\Sales\Api\Data\OrderInterface;
14+
use Magento\Sales\Api\OrderRepositoryInterface;
15+
use Magento\Sales\Model\Order\CustomerAssignment;
16+
17+
/**
18+
* Test for Magento\Sales\Model\Order\CustomerAssignment class.
19+
*/
20+
class CustomerAssigmentTest extends \PHPUnit\Framework\TestCase
21+
{
22+
/**
23+
* @var CustomerAssignment
24+
*/
25+
private $customerAssignment;
26+
27+
/**
28+
* @var OrderInterface|\PHPUnit\Framework\MockObject\MockObject
29+
*/
30+
private $orderMock;
31+
32+
/**
33+
* @var CustomerInterface|\PHPUnit\Framework\MockObject\MockObject
34+
*/
35+
private $customerMock;
36+
37+
/**
38+
* @var OrderRepositoryInterface|\PHPUnit\Framework\MockObject\MockObject
39+
*/
40+
private $orderRepositoryMock;
41+
42+
/**
43+
* @var ManagerInterface|\PHPUnit\Framework\MockObject\MockObject
44+
*/
45+
private $eventManagerMock;
46+
47+
/**
48+
* Tests 'execute' method.
49+
*
50+
* @dataProvider executeDataProvider
51+
* @param array $data
52+
*/
53+
public function testExecute(array $data): void
54+
{
55+
$this->configureOrderMock($data);
56+
$this->configureCustomerMock($data);
57+
$this->orderRepositoryMock->expects($this->once())->method('save')->with($this->orderMock);
58+
$this->eventManagerMock->expects($this->once())->method('dispatch')->with(
59+
'sales_order_customer_assign_after',
60+
[
61+
'order' => $this->orderMock,
62+
'customer' => $this->customerMock
63+
]
64+
);
65+
66+
$this->customerAssignment->execute($this->orderMock, $this->customerMock);
67+
}
68+
69+
/**
70+
*
71+
* Data provider for testExecute.
72+
* @return array
73+
*/
74+
public function executeDataProvider(): array
75+
{
76+
return [
77+
[
78+
[
79+
'customerId' => 1,
80+
'customerIsGuest' => false,
81+
'customerEmail' => 'customerEmail',
82+
'customerFirstname' => 'customerFirstname',
83+
'customerLastname' => 'customerLastname',
84+
'customerMiddlename' => 'customerMiddlename',
85+
'customerPrefix' => 'customerPrefix',
86+
'customerSuffix' => 'customerSuffix',
87+
'customerGroupId' => 'customerGroupId',
88+
],
89+
],
90+
];
91+
}
92+
93+
/**
94+
* @return void
95+
*/
96+
protected function setUp()
97+
{
98+
$objectManager = new ObjectManager($this);
99+
$this->orderMock = $this->createMock(OrderInterface::class);
100+
$this->customerMock = $this->createMock(CustomerInterface::class);
101+
$this->orderRepositoryMock = $this->createMock(OrderRepositoryInterface::class);
102+
$this->eventManagerMock = $this->createMock(ManagerInterface::class);
103+
$this->customerAssignment = $objectManager->getObject(
104+
CustomerAssignment::class,
105+
[
106+
'eventManager' => $this->eventManagerMock,
107+
'orderRepository' => $this->orderRepositoryMock
108+
]
109+
);
110+
}
111+
112+
/**
113+
* Set up order mock.
114+
*
115+
* @param array $data
116+
*/
117+
private function configureOrderMock(array $data): void
118+
{
119+
$this->orderMock->expects($this->once())->method('setCustomerId')->with($data['customerId'])
120+
->willReturn($this->orderMock);
121+
$this->orderMock->expects($this->once())->method('setCustomerIsGuest')->with($data['customerIsGuest'])
122+
->willReturn($this->orderMock);
123+
$this->orderMock->expects($this->once())->method('setCustomerEmail')->with($data['customerEmail'])
124+
->willReturn($this->orderMock);
125+
$this->orderMock->expects($this->once())->method('setCustomerFirstname')->with($data['customerFirstname'])
126+
->willReturn($this->orderMock);
127+
$this->orderMock->expects($this->once())->method('setCustomerLastname')->with($data['customerLastname'])
128+
->willReturn($this->orderMock);
129+
$this->orderMock->expects($this->once())->method('setCustomerMiddlename')->with($data['customerMiddlename'])
130+
->willReturn($this->orderMock);
131+
$this->orderMock->expects($this->once())->method('setCustomerPrefix')->with($data['customerPrefix'])
132+
->willReturn($this->orderMock);
133+
$this->orderMock->expects($this->once())->method('setCustomerSuffix')->with($data['customerSuffix'])
134+
->willReturn($this->orderMock);
135+
$this->orderMock->expects($this->once())->method('setCustomerGroupId')->with($data['customerGroupId'])
136+
->willReturn($this->orderMock);
137+
}
138+
139+
/**
140+
* Set up customer mock.
141+
*
142+
* @param array $data
143+
*/
144+
private function configureCustomerMock(array $data): void
145+
{
146+
$this->customerMock->expects($this->once())->method('getId')->willReturn($data['customerId']);
147+
$this->customerMock->expects($this->once())->method('getEmail')->willReturn($data['customerEmail']);
148+
$this->customerMock->expects($this->once())->method('getFirstname')->willReturn($data['customerFirstname']);
149+
$this->customerMock->expects($this->once())->method('getLastname')->willReturn($data['customerLastname']);
150+
$this->customerMock->expects($this->once())->method('getMiddlename')->willReturn($data['customerMiddlename']);
151+
$this->customerMock->expects($this->once())->method('getPrefix')->willReturn($data['customerPrefix']);
152+
$this->customerMock->expects($this->once())->method('getSuffix')->willReturn($data['customerSuffix']);
153+
$this->customerMock->expects($this->once())->method('getGroupId')->willReturn($data['customerGroupId']);
154+
}
155+
}

0 commit comments

Comments
 (0)