Skip to content

Commit e45a5d6

Browse files
authored
Merge pull request #5915 from magento-tango/PR-2020-07-21
[tango] Bugfix delivery
2 parents bc9e5cf + 0afb093 commit e45a5d6

File tree

36 files changed

+614
-99
lines changed

36 files changed

+614
-99
lines changed

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

Lines changed: 5 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,

app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/**
77
* @api
88
*/
9-
define([], function () {
9+
define(['underscore'], function (_) {
1010
'use strict';
1111

1212
/**
@@ -44,7 +44,7 @@ define([], function () {
4444
vatId: addressData['vat_id'],
4545
sameAsBilling: addressData['same_as_billing'],
4646
saveInAddressBook: addressData['save_in_address_book'],
47-
customAttributes: addressData['custom_attributes'],
47+
customAttributes: _.toArray(addressData['custom_attributes']).reverse(),
4848

4949
/**
5050
* @return {*}

app/code/Magento/Downloadable/Observer/SaveDownloadableOrderItemObserver.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,14 @@ public function __construct(
8181
*/
8282
public function execute(\Magento\Framework\Event\Observer $observer)
8383
{
84+
/** @var \Magento\Sales\Model\Order\Item $orderItem */
8485
$orderItem = $observer->getEvent()->getItem();
8586
if (!$orderItem->getId()) {
8687
//order not saved in the database
8788
return $this;
8889
}
89-
if ($orderItem->getProductType() != \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
90+
$productType = $orderItem->getRealProductType() ?: $orderItem->getProductType();
91+
if ($productType != \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
9092
return $this;
9193
}
9294
$product = $orderItem->getProduct();
@@ -112,13 +114,13 @@ public function execute(\Magento\Framework\Event\Observer $observer)
112114
if ($linkIds = $orderItem->getProductOptionByCode('links')) {
113115
$linkPurchased = $this->_createPurchasedModel();
114116
$this->_objectCopyService->copyFieldsetToTarget(
115-
\downloadable_sales_copy_order::class,
117+
'downloadable_sales_copy_order',
116118
'to_downloadable',
117119
$orderItem->getOrder(),
118120
$linkPurchased
119121
);
120122
$this->_objectCopyService->copyFieldsetToTarget(
121-
\downloadable_sales_copy_order_item::class,
123+
'downloadable_sales_copy_order_item',
122124
'to_downloadable',
123125
$orderItem,
124126
$linkPurchased
@@ -131,14 +133,12 @@ public function execute(\Magento\Framework\Event\Observer $observer)
131133
ScopeInterface::SCOPE_STORE
132134
);
133135
$linkPurchased->setLinkSectionTitle($linkSectionTitle)->save();
134-
135136
$linkStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING;
136137
if ($orderStatusToEnableItem == \Magento\Sales\Model\Order\Item::STATUS_PENDING
137138
|| $orderItem->getOrder()->getState() == \Magento\Sales\Model\Order::STATE_COMPLETE
138139
) {
139140
$linkStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE;
140141
}
141-
142142
foreach ($linkIds as $linkId) {
143143
if (isset($links[$linkId])) {
144144
$linkPurchasedItem = $this->_createPurchasedItemModel()->setPurchasedId(
@@ -148,7 +148,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
148148
);
149149

150150
$this->_objectCopyService->copyFieldsetToTarget(
151-
\downloadable_sales_copy_link::class,
151+
'downloadable_sales_copy_link',
152152
'to_purchased',
153153
$links[$linkId],
154154
$linkPurchasedItem

app/code/Magento/Downloadable/Test/Unit/Observer/SaveDownloadableOrderItemObserverTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ public function testSaveDownloadableOrderItem()
160160
$itemMock->expects($this->any())
161161
->method('getProductType')
162162
->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
163+
$itemMock->expects($this->any())
164+
->method('getRealProductType')
165+
->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
163166

164167
$this->orderMock->expects($this->once())
165168
->method('getStoreId')
@@ -295,6 +298,9 @@ public function testSaveDownloadableOrderItemSavedPurchasedLink()
295298
$itemMock->expects($this->any())
296299
->method('getProductType')
297300
->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
301+
$itemMock->expects($this->any())
302+
->method('getRealProductType')
303+
->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
298304

299305
$purchasedLink = $this->getMockBuilder(\Magento\Downloadable\Model\Link\Purchased::class)
300306
->disableOriginalConstructor()

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
@@ -104,6 +104,7 @@ public function __construct(
104104
* @param array $context
105105
* @return array
106106
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
107+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
107108
*/
108109
public function getFields(array $context = []): array
109110
{
@@ -120,6 +121,9 @@ public function getFields(array $context = []): array
120121
$allAttributes[$fieldName] = [
121122
'type' => $this->fieldTypeResolver->getFieldType($attributeAdapter),
122123
];
124+
if ($this->isNeedToAddCustomAnalyzer($fieldName) && $this->getCustomAnalyzer($fieldName)) {
125+
$allAttributes[$fieldName]['analyzer'] = $this->getCustomAnalyzer($fieldName);
126+
}
123127

124128
$index = $this->fieldIndexResolver->getFieldIndex($attributeAdapter);
125129
if (null !== $index) {
@@ -174,4 +178,26 @@ public function getFields(array $context = []): array
174178

175179
return $allAttributes;
176180
}
181+
182+
/**
183+
* Check is the custom analyzer exists for the field
184+
*
185+
* @param string $fieldName
186+
* @return bool
187+
*/
188+
private function isNeedToAddCustomAnalyzer(string $fieldName): bool
189+
{
190+
return $fieldName === 'sku';
191+
}
192+
193+
/**
194+
* Getter for the field custom analyzer if it's exists
195+
*
196+
* @param string $fieldName
197+
* @return string|null
198+
*/
199+
private function getCustomAnalyzer(string $fieldName): ?string
200+
{
201+
return $fieldName === 'sku' ? 'sku' : null;
202+
}
177203
}

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/Persistent/Observer/SynchronizePersistentOnLoginObserver.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
/**
1313
* Persistent Session Observer
14+
*
15+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
16+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1417
*/
1518
class SynchronizePersistentOnLoginObserver implements ObserverInterface
1619
{
@@ -63,6 +66,8 @@ public function __construct(
6366
}
6467

6568
/**
69+
* Synchronize persistent session data with logged in customer
70+
*
6671
* @param Observer $observer
6772
* @return void
6873
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -96,8 +101,9 @@ public function execute(Observer $observer)
96101
if (!$sessionModel->getId()) {
97102
/** @var \Magento\Persistent\Model\Session $sessionModel */
98103
$sessionModel = $this->_sessionFactory->create();
99-
$sessionModel->setCustomerId($customer->getId())->save();
104+
$sessionModel->setCustomerId($customer->getId());
100105
}
106+
$sessionModel->save();
101107
$this->_persistentSession->setSession($sessionModel);
102108
}
103109

app/code/Magento/Sales/view/frontend/email/creditmemo_new_guest.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"var comment|escape|nl2br":"Credit Memo Comment",
1111
"var creditmemo.increment_id":"Credit Memo Id",
1212
"layout handle=\"sales_email_order_creditmemo_items\" creditmemo=$creditmemo order=$order":"Credit Memo Items Grid",
13-
"var billing.name":"Guest Customer Name (Billing)",
13+
"var order_data.customer_name":"Guest Customer Name (Billing)",
1414
"var order.increment_id":"Order Id",
1515
"var payment_html|raw":"Payment Details",
1616
"var formattedShippingAddress|raw":"Shipping Address",
@@ -30,7 +30,7 @@
3030
<table>
3131
<tr class="email-intro">
3232
<td>
33-
<p class="greeting">{{trans "%name," name=$billing.name}}</p>
33+
<p class="greeting">{{trans "%name," name=$order_data.customer_name}}</p>
3434
<p>
3535
{{trans "Thank you for your order from %store_name." store_name=$store.frontend_name}}
3636
{{trans 'If you have questions about your order, you can email us at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.

app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!--@vars {
99
"var comment|escape|nl2br":"Credit Memo Comment",
1010
"var creditmemo.increment_id":"Credit Memo Id",
11-
"var billing.name":"Guest Customer Name",
11+
"var order_data.customer_name":"Guest Customer Name",
1212
"var order.increment_id":"Order Id",
1313
"var order_data.frontend_status_label":"Order Status",
1414
"var store.frontend_name":"Store Frontend Name",
@@ -21,7 +21,7 @@
2121
<table>
2222
<tr class="email-intro">
2323
<td>
24-
<p class="greeting">{{trans "%name," name=$billing.name}}</p>
24+
<p class="greeting">{{trans "%name," name=$order_data.customer_name}}</p>
2525
<p>
2626
{{trans
2727
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."

app/code/Magento/Sales/view/frontend/email/invoice_new_guest.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!--@subject {{trans "Invoice for your %store_name order" store_name=$store.frontend_name}} @-->
88
<!--@vars {
99
"var formattedBillingAddress|raw":"Billing Address",
10-
"var billing.name":"Guest Customer Name",
10+
"var order_data.customer_name":"Guest Customer Name",
1111
"var comment|escape|nl2br":"Invoice Comment",
1212
"var invoice.increment_id":"Invoice Id",
1313
"layout handle=\"sales_email_order_invoice_items\" invoice=$invoice order=$order":"Invoice Items Grid",
@@ -30,7 +30,7 @@
3030
<table>
3131
<tr class="email-intro">
3232
<td>
33-
<p class="greeting">{{trans "%name," name=$billing.name}}</p>
33+
<p class="greeting">{{trans "%name," name=$order_data.customer_name}}</p>
3434
<p>
3535
{{trans "Thank you for your order from %store_name." store_name=$store.frontend_name}}
3636
{{trans 'If you have questions about your order, you can email us at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.

0 commit comments

Comments
 (0)