Skip to content

Commit e23e810

Browse files
authored
Merge pull request #6003 from magento-tango/PR-08-10-2020
[tango] MC-36015: Update in Order Status Does Not Reflect in Email
2 parents 5173b44 + 46e8da2 commit e23e810

File tree

17 files changed

+329
-30
lines changed

17 files changed

+329
-30
lines changed

app/code/Magento/CatalogSearch/Model/Advanced.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ public function addFilters($values)
233233
? date('Y-m-d\TH:i:s\Z', strtotime($value['to']))
234234
: '';
235235
}
236+
237+
if ($attribute->getAttributeCode() === 'sku') {
238+
$value = mb_strtolower($value);
239+
}
240+
236241
$condition = $this->_getResource()->prepareCondition(
237242
$attribute,
238243
$value,
@@ -356,6 +361,8 @@ protected function addSearchCriteria($attribute, $value)
356361
*/
357362
protected function getPreparedSearchCriteria($attribute, $value)
358363
{
364+
$from = null;
365+
$to = null;
359366
if (is_array($value)) {
360367
if (isset($value['from']) && isset($value['to'])) {
361368
if (!empty($value['from']) || !empty($value['to'])) {

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ define([
3838

3939
if (new Date($.localStorage.get('mage-cache-timeout')) < new Date()) {
4040
storage.removeAll();
41-
date = new Date(Date.now() + parseInt(invalidateOptions.cookieLifeTime, 10) * 1000);
42-
$.localStorage.set('mage-cache-timeout', date);
4341
}
42+
date = new Date(Date.now() + parseInt(invalidateOptions.cookieLifeTime, 10) * 1000);
43+
$.localStorage.set('mage-cache-timeout', date);
4444
};
4545

4646
/**

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,15 @@ protected function beforeAddLoadedItem(\Magento\Framework\DataObject $item)
8787
$this->entitySnapshot->registerSnapshot($item);
8888
return $item;
8989
}
90+
91+
/**
92+
* Clear collection
93+
*
94+
* @return $this
95+
*/
96+
public function clear()
97+
{
98+
$this->entitySnapshot->clear($this->getNewEmptyItem());
99+
return parent::clear();
100+
}
90101
}

app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/VersionControl/AbstractCollectionTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function setUp(): void
3636

3737
$this->entitySnapshot = $this->createPartialMock(
3838
Snapshot::class,
39-
['registerSnapshot']
39+
['registerSnapshot', 'clear']
4040
);
4141

4242
$this->subject = $objectManager->getObject(
@@ -82,4 +82,11 @@ public static function fetchItemDataProvider()
8282
[['attribute' => 'test']]
8383
];
8484
}
85+
86+
public function testClearSnapshot()
87+
{
88+
$item = $this->getMagentoObject();
89+
$this->entitySnapshot->expects($this->once())->method('clear')->with($item);
90+
$this->subject->clear();
91+
}
8592
}

app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function __construct(
103103
* @param array $context
104104
* @return array
105105
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
106+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
106107
*/
107108
public function getFields(array $context = []): array
108109
{
@@ -140,6 +141,9 @@ public function getField(AbstractAttribute $attribute): array
140141
$fieldMapping[$fieldName] = [
141142
'type' => $this->fieldTypeResolver->getFieldType($attributeAdapter),
142143
];
144+
if ($this->isNeedToAddCustomAnalyzer($fieldName) && $this->getCustomAnalyzer($fieldName)) {
145+
$fieldMapping[$fieldName]['analyzer'] = $this->getCustomAnalyzer($fieldName);
146+
}
143147

144148
$index = $this->fieldIndexResolver->getFieldIndex($attributeAdapter);
145149
if (null !== $index) {
@@ -188,4 +192,26 @@ public function getField(AbstractAttribute $attribute): array
188192

189193
return $fieldMapping;
190194
}
195+
196+
/**
197+
* Check is the custom analyzer exists for the field
198+
*
199+
* @param string $fieldName
200+
* @return bool
201+
*/
202+
private function isNeedToAddCustomAnalyzer(string $fieldName): bool
203+
{
204+
return $fieldName === 'sku';
205+
}
206+
207+
/**
208+
* Getter for the field custom analyzer if it's exists
209+
*
210+
* @param string $fieldName
211+
* @return string|null
212+
*/
213+
private function getCustomAnalyzer(string $fieldName): ?string
214+
{
215+
return $fieldName === 'sku' ? 'sku' : null;
216+
}
191217
}

app/code/Magento/Elasticsearch/Model/Adapter/Index/Builder.php

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Magento\Framework\Locale\Resolver as LocaleResolver;
99
use Magento\Elasticsearch\Model\Adapter\Index\Config\EsConfigInterface;
1010

11+
/**
12+
* Index Builder
13+
*/
1114
class Builder implements BuilderInterface
1215
{
1316
/**
@@ -40,7 +43,7 @@ public function __construct(
4043
}
4144

4245
/**
43-
* {@inheritdoc}
46+
* @inheritdoc
4447
*/
4548
public function build()
4649
{
@@ -59,6 +62,14 @@ public function build()
5962
array_keys($filter)
6063
),
6164
'char_filter' => array_keys($charFilter)
65+
],
66+
'sku' => [
67+
'type' => 'custom',
68+
'tokenizer' => 'keyword',
69+
'filter' => array_merge(
70+
['lowercase', 'keyword_repeat'],
71+
array_keys($filter)
72+
),
6273
]
6374
],
6475
'tokenizer' => $tokenizer,
@@ -71,55 +82,63 @@ public function build()
7182
}
7283

7384
/**
74-
* {@inheritdoc}
85+
* Setter for storeId property
86+
*
87+
* @param int $storeId
88+
* @return void
7589
*/
7690
public function setStoreId($storeId)
7791
{
7892
$this->storeId = $storeId;
7993
}
8094

8195
/**
96+
* Return tokenizer configuration
97+
*
8298
* @return array
8399
*/
84100
protected function getTokenizer()
85101
{
86-
$tokenizer = [
102+
return [
87103
'default_tokenizer' => [
88-
'type' => 'standard',
89-
],
104+
'type' => 'standard'
105+
]
90106
];
91-
return $tokenizer;
92107
}
93108

94109
/**
110+
* Return filter configuration
111+
*
95112
* @return array
96113
*/
97114
protected function getFilter()
98115
{
99-
$filter = [
116+
return [
100117
'default_stemmer' => $this->getStemmerConfig(),
101118
'unique_stem' => [
102119
'type' => 'unique',
103120
'only_on_same_position' => true
104121
]
105122
];
106-
return $filter;
107123
}
108124

109125
/**
126+
* Return char filter configuration
127+
*
110128
* @return array
111129
*/
112130
protected function getCharFilter()
113131
{
114-
$charFilter = [
132+
return [
115133
'default_char_filter' => [
116134
'type' => 'html_strip',
117135
],
118136
];
119-
return $charFilter;
120137
}
121138

122139
/**
140+
* Return stemmer configuration
141+
*
123142
* @return array
124143
*/
125144
protected function getStemmerConfig()

app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
/**
1212
* Class AddComment
13+
*
14+
* Controller responsible for addition of the order comment to the order
1315
*/
1416
class AddComment extends \Magento\Sales\Controller\Adminhtml\Order implements HttpPostActionInterface
1517
{
@@ -42,6 +44,7 @@ public function execute()
4244
);
4345
}
4446

47+
$order->setStatus($data['status']);
4548
$notify = $data['is_customer_notified'] ?? false;
4649
$visible = $data['is_visible_on_front'] ?? false;
4750

app/code/Magento/Sales/Model/Order/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Config
5252
*/
5353
protected $maskStatusesMapping = [
5454
\Magento\Framework\App\Area::AREA_FRONTEND => [
55-
\Magento\Sales\Model\Order::STATUS_FRAUD => \Magento\Sales\Model\Order::STATE_PROCESSING,
55+
\Magento\Sales\Model\Order::STATUS_FRAUD => \Magento\Sales\Model\Order::STATUS_FRAUD,
5656
\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW => \Magento\Sales\Model\Order::STATE_PROCESSING
5757
]
5858
];

app/code/Magento/User/Observer/Backend/TrackAdminNewPasswordObserver.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,57 @@
88

99
use Magento\Framework\Event\Observer as EventObserver;
1010
use Magento\Framework\Event\ObserverInterface;
11+
use Magento\Framework\Message\ManagerInterface;
1112
use Magento\User\Model\User;
13+
use Magento\User\Model\Backend\Config\ObserverConfig;
14+
use Magento\User\Model\ResourceModel\User as UserResource;
15+
use Magento\Backend\Model\Auth\Session as AuthSession;
1216

1317
/**
1418
* User backend observer model for passwords
19+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1520
*/
1621
class TrackAdminNewPasswordObserver implements ObserverInterface
1722
{
1823
/**
1924
* Backend configuration interface
2025
*
21-
* @var \Magento\User\Model\Backend\Config\ObserverConfig
26+
* @var ObserverConfig
2227
*/
2328
protected $observerConfig;
2429

2530
/**
2631
* Admin user resource model
2732
*
28-
* @var \Magento\User\Model\ResourceModel\User
33+
* @var UserResource
2934
*/
3035
protected $userResource;
3136

3237
/**
3338
* Backend authorization session
3439
*
35-
* @var \Magento\Backend\Model\Auth\Session
40+
* @var AuthSession
3641
*/
3742
protected $authSession;
3843

3944
/**
4045
* Message manager interface
4146
*
42-
* @var \Magento\Framework\Message\ManagerInterface
47+
* @var ManagerInterface
4348
*/
4449
protected $messageManager;
4550

4651
/**
47-
* @param \Magento\User\Model\Backend\Config\ObserverConfig $observerConfig
48-
* @param \Magento\User\Model\ResourceModel\User $userResource
49-
* @param \Magento\Backend\Model\Auth\Session $authSession
50-
* @param \Magento\Framework\Message\ManagerInterface $messageManager
52+
* @param ObserverConfig $observerConfig
53+
* @param UserResource $userResource
54+
* @param AuthSession $authSession
55+
* @param ManagerInterface $messageManager
5156
*/
5257
public function __construct(
53-
\Magento\User\Model\Backend\Config\ObserverConfig $observerConfig,
54-
\Magento\User\Model\ResourceModel\User $userResource,
55-
\Magento\Backend\Model\Auth\Session $authSession,
56-
\Magento\Framework\Message\ManagerInterface $messageManager
58+
ObserverConfig $observerConfig,
59+
UserResource $userResource,
60+
AuthSession $authSession,
61+
ManagerInterface $messageManager
5762
) {
5863
$this->observerConfig = $observerConfig;
5964
$this->userResource = $userResource;
@@ -69,11 +74,11 @@ public function __construct(
6974
*/
7075
public function execute(EventObserver $observer)
7176
{
72-
/* @var $user \Magento\User\Model\User */
77+
/* @var $user User */
7378
$user = $observer->getEvent()->getObject();
7479
if ($user->getId()) {
7580
$passwordHash = $user->getPassword();
76-
if ($passwordHash && !$user->getForceNewPassword()) {
81+
if ($passwordHash && $user->dataHasChangedFor('password')) {
7782
$this->userResource->trackPassword($user, $passwordHash);
7883
$this->messageManager->getMessages()->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED);
7984
$this->authSession->unsPciAdminUserIsPasswordExpired();

app/code/Magento/User/Test/Unit/Observer/Backend/TrackAdminNewPasswordObserverTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,17 @@ public function testTrackAdminPassword()
112112
/** @var \Magento\User\Model\User|MockObject $userMock */
113113
$userMock = $this->getMockBuilder(\Magento\User\Model\User::class)
114114
->disableOriginalConstructor()
115-
->setMethods(['getId', 'getPassword', 'getForceNewPassword'])
115+
->setMethods(['getId', 'getPassword', 'dataHasChangedFor'])
116116
->getMock();
117117

118118
$eventObserverMock->expects($this->once())->method('getEvent')->willReturn($eventMock);
119119
$eventMock->expects($this->once())->method('getObject')->willReturn($userMock);
120120
$userMock->expects($this->once())->method('getId')->willReturn($uid);
121121
$userMock->expects($this->once())->method('getPassword')->willReturn($newPW);
122-
$userMock->expects($this->once())->method('getForceNewPassword')->willReturn(false);
122+
$userMock->expects($this->once())
123+
->method('dataHasChangedFor')
124+
->with('password')
125+
->willReturn(true);
123126

124127
/** @var Collection|MockObject $collectionMock */
125128
$collectionMock = $this->getMockBuilder(Collection::class)

0 commit comments

Comments
 (0)