Skip to content

Commit ee5a96a

Browse files
author
Hwashiang Yu
committed
Merge remote-tracking branch 'upstream/2.3-develop' into MC-34648
2 parents b5ee18f + e45a5d6 commit ee5a96a

File tree

44 files changed

+775
-454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+775
-454
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CatalogRuleGraphQl
2+
3+
The *Magento_CatalogRuleGraphQl* module applies catalog rules to products for GraphQL requests.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "magento/module-catalog-rule-graph-ql",
3+
"description": "N/A",
4+
"type": "magento2-module",
5+
"require": {
6+
"php": "~7.1.3||~7.2.0||~7.3.0",
7+
"magento/framework": "*"
8+
},
9+
"suggest": {
10+
"magento/module-catalog-rule": "*"
11+
},
12+
"license": [
13+
"OSL-3.0",
14+
"AFL-3.0"
15+
],
16+
"autoload": {
17+
"files": [
18+
"registration.php"
19+
],
20+
"psr-4": {
21+
"Magento\\CatalogRuleGraphQl\\": ""
22+
}
23+
}
24+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
9+
<event name="catalog_product_get_final_price">
10+
<observer name="catalogrule" instance="Magento\CatalogRule\Observer\ProcessFrontFinalPriceObserver" />
11+
</event>
12+
<event name="prepare_catalog_product_collection_prices">
13+
<observer name="catalogrule" instance="Magento\CatalogRule\Observer\PrepareCatalogProductCollectionPricesObserver" />
14+
</event>
15+
</config>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_CatalogRuleGraphQl" />
10+
</config>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Framework\Component\ComponentRegistrar;
8+
9+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_CatalogRuleGraphQl', __DIR__);

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
}

0 commit comments

Comments
 (0)