Skip to content

Commit 02d2027

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MAGETWO-91545
# Conflicts: # dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml
2 parents 34cbc8e + f8b3385 commit 02d2027

File tree

128 files changed

+4094
-683
lines changed

Some content is hidden

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

128 files changed

+4094
-683
lines changed

app/code/Magento/Bundle/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
},
2626
"suggest": {
2727
"magento/module-webapi": "*",
28-
"magento/module-bundle-sample-data": "*"
28+
"magento/module-bundle-sample-data": "*",
29+
"magento/module-sales-rule": "*"
2930
},
3031
"type": "magento2-module",
3132
"license": [

app/code/Magento/Bundle/etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,11 @@
207207
</argument>
208208
</arguments>
209209
</type>
210+
<type name="Magento\SalesRule\Model\Quote\ChildrenValidationLocator">
211+
<arguments>
212+
<argument name="productTypeChildrenValidationMap" xsi:type="array">
213+
<item name="bundle" xsi:type="boolean">false</item>
214+
</argument>
215+
</arguments>
216+
</type>
210217
</config>

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Save extends Attribute
6969
* @var LayoutFactory
7070
*/
7171
private $layoutFactory;
72+
7273
/**
7374
* @var Presentation
7475
*/
@@ -124,6 +125,7 @@ public function execute()
124125
{
125126
$data = $this->getRequest()->getPostValue();
126127
if ($data) {
128+
$this->preprocessOptionsData($data);
127129
$setId = $this->getRequest()->getParam('set');
128130

129131
$attributeSet = null;
@@ -313,6 +315,28 @@ public function execute()
313315
return $this->returnResult('catalog/*/', [], ['error' => true]);
314316
}
315317

318+
/**
319+
* Extract options data from serialized options field and append to data array.
320+
*
321+
* This logic is required to overcome max_input_vars php limit
322+
* that may vary and/or be inaccessible to change on different instances.
323+
*
324+
* @param array $data
325+
* @return void
326+
*/
327+
private function preprocessOptionsData(&$data)
328+
{
329+
if (isset($data['serialized_options'])) {
330+
$serializedOptions = json_decode($data['serialized_options'], JSON_OBJECT_AS_ARRAY);
331+
foreach ($serializedOptions as $serializedOption) {
332+
$option = [];
333+
parse_str($serializedOption, $option);
334+
$data = array_replace_recursive($data, $option);
335+
}
336+
}
337+
unset($data['serialized_options']);
338+
}
339+
316340
/**
317341
* @param string $path
318342
* @param array $params

app/code/Magento/Catalog/view/adminhtml/web/js/options.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ define([
1313
'jquery/ui',
1414
'prototype',
1515
'form',
16-
'validation'
16+
'validation',
17+
'mage/translate'
1718
], function (jQuery, mageTemplate, rg) {
1819
'use strict';
1920

2021
return function (config) {
21-
var attributeOption = {
22+
var optionPanel = jQuery('#manage-options-panel'),
23+
optionsValues = [],
24+
editForm = jQuery('#edit_form'),
25+
attributeOption = {
2226
table: $('attribute-options-table'),
2327
itemCount: 0,
2428
totalItems: 0,
@@ -150,7 +154,7 @@ define([
150154
attributeOption.remove(event);
151155
});
152156

153-
jQuery('#manage-options-panel').on('render', function () {
157+
optionPanel.on('render', function () {
154158
attributeOption.ignoreValidate();
155159

156160
if (attributeOption.rendered) {
@@ -176,7 +180,31 @@ define([
176180
});
177181
});
178182
}
183+
editForm.on('submit', function () {
184+
optionPanel.find('input')
185+
.each(function () {
186+
if (this.disabled) {
187+
return;
188+
}
179189

190+
if (this.type === 'checkbox' || this.type === 'radio') {
191+
if (this.checked) {
192+
optionsValues.push(this.name + '=' + jQuery(this).val());
193+
}
194+
} else {
195+
optionsValues.push(this.name + '=' + jQuery(this).val());
196+
}
197+
});
198+
jQuery('<input>')
199+
.attr({
200+
type: 'hidden',
201+
name: 'serialized_options'
202+
})
203+
.val(JSON.stringify(optionsValues))
204+
.prependTo(editForm);
205+
optionPanel.find('table')
206+
.replaceWith(jQuery('<div>').text(jQuery.mage.__('Sending attribute values as package.')));
207+
});
180208
window.attributeOption = attributeOption;
181209
window.optionDefaultInputType = attributeOption.getOptionInputType();
182210

app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
*/
1515
interface StockStatusInterface extends ExtensibleDataInterface
1616
{
17+
/**#@+
18+
* Stock Status values.
19+
*/
20+
const STATUS_OUT_OF_STOCK = 0;
21+
22+
const STATUS_IN_STOCK = 1;
23+
/**#@-*/
24+
1725
/**#@+
1826
* Stock status object data keys
1927
*/

app/code/Magento/CatalogInventory/Model/Stock/Status.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717
*/
1818
class Status extends AbstractExtensibleModel implements StockStatusInterface
1919
{
20-
/**#@+
21-
* Stock Status values
22-
*/
23-
const STATUS_OUT_OF_STOCK = 0;
24-
25-
const STATUS_IN_STOCK = 1;
26-
/**#@-*/
27-
2820
/**#@+
2921
* Field name
3022
*/

app/code/Magento/Customer/view/frontend/templates/form/login.phtml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,13 @@
4242
</form>
4343
</div>
4444
</div>
45+
46+
<script type="text/x-magento-init">
47+
{
48+
".field.email": {
49+
"Magento_Customer/js/trim-username": {
50+
"formSelector": "form.form-login"
51+
}
52+
}
53+
}
54+
</script>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery'
8+
], function ($) {
9+
'use strict';
10+
11+
$.widget('mage.trimUsername', {
12+
options: {
13+
cache: {},
14+
formSelector: 'form',
15+
emailSelector: 'input[type="email"]'
16+
},
17+
18+
/**
19+
* Widget initialization
20+
* @private
21+
*/
22+
_create: function () {
23+
// We need to look outside the module for backward compatibility, since someone can already use the module.
24+
// @todo Narrow this selector in 2.3 so it doesn't accidentally finds the email field from the
25+
// newsletter email field or any other "email" field.
26+
this.options.cache.email = $(this.options.formSelector).find(this.options.emailSelector);
27+
this._bind();
28+
},
29+
30+
/**
31+
* Event binding, will monitor change, keyup and paste events.
32+
* @private
33+
*/
34+
_bind: function () {
35+
if (this.options.cache.email.length) {
36+
this._on(this.options.cache.email, {
37+
'change': this._trimUsername,
38+
'keyup': this._trimUsername,
39+
'paste': this._trimUsername
40+
});
41+
}
42+
},
43+
44+
/**
45+
* Trim username
46+
* @private
47+
*/
48+
_trimUsername: function () {
49+
var username = this._getUsername().trim();
50+
51+
this.options.cache.email.val(username);
52+
},
53+
54+
/**
55+
* Get username value
56+
* @returns {*}
57+
* @private
58+
*/
59+
_getUsername: function () {
60+
return this.options.cache.email.val();
61+
}
62+
});
63+
64+
return $.mage.trimUsername;
65+
});

app/code/Magento/Elasticsearch/Model/Config.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Elasticsearch\Model;
77

88
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
use Magento\Framework\Search\EngineResolverInterface;
10+
use Magento\Search\Model\EngineResolver;
911
use Magento\Store\Model\ScopeInterface;
1012
use Magento\AdvancedSearch\Model\Client\ClientOptionsInterface;
1113
use Magento\AdvancedSearch\Model\Client\ClientResolver;
@@ -54,21 +56,28 @@ class Config implements ClientOptionsInterface
5456
*/
5557
private $clientResolver;
5658

59+
/**
60+
* @var EngineResolverInterface
61+
*/
62+
private $engineResolver;
63+
5764
/**
5865
* Constructor
5966
*
6067
* @param ScopeConfigInterface $scopeConfig
61-
* @param ClientResolver $clientResolver
62-
* @param string $prefix
68+
* @param ClientResolver|null $clientResolver
69+
* @param EngineResolverInterface|null $engineResolver
70+
* @param string|null $prefix
6371
*/
6472
public function __construct(
6573
ScopeConfigInterface $scopeConfig,
6674
ClientResolver $clientResolver = null,
75+
EngineResolverInterface $engineResolver = null,
6776
$prefix = null
6877
) {
6978
$this->scopeConfig = $scopeConfig;
70-
$this->clientResolver = $clientResolver ?:
71-
ObjectManager::getInstance()->get(ClientResolver::class);
79+
$this->clientResolver = $clientResolver ?: ObjectManager::getInstance()->get(ClientResolver::class);
80+
$this->engineResolver = $engineResolver ?: ObjectManager::getInstance()->get(EngineResolverInterface::class);
7281
$this->prefix = $prefix ?: $this->clientResolver->getCurrentEngine();
7382
}
7483

@@ -126,7 +135,7 @@ public function getSearchConfigData($field, $storeId = null)
126135
*/
127136
public function isElasticsearchEnabled()
128137
{
129-
return $this->getSearchConfigData('engine') == self::ENGINE_NAME;
138+
return $this->engineResolver->getCurrentSearchEngine() === self::ENGINE_NAME;
130139
}
131140

132141
/**
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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\Elasticsearch\Model\Indexer\Plugin;
9+
10+
use Magento\Elasticsearch\Model\Config;
11+
use Magento\Framework\Indexer\Config\DependencyInfoProvider as Provider;
12+
use Magento\CatalogSearch\Model\Indexer\Fulltext as CatalogSearchFulltextIndexer;
13+
use Magento\CatalogInventory\Model\Indexer\Stock\Processor as CatalogInventoryStockIndexer;
14+
15+
/**
16+
* Plugin for maintenance catalog search index dependency on stock index.
17+
* If elasticsearch is used as search engine catalog search index becomes dependent on stock index. Elasticsearch
18+
* module declares this dependence. But in case when elasticsearch module is enabled and elasticsearch engine isn`t
19+
* used as search engine other search engines don`t need this dependency.
20+
* This plugin remove catalog search index dependency on stock index when elasticsearch isn`t used as search engine
21+
* except full reindexing. During full reindexing this dependency doesn`t make overhead.
22+
*/
23+
class DependencyUpdaterPlugin
24+
{
25+
/**
26+
* @var Config
27+
*/
28+
private $config;
29+
30+
/**
31+
* @param Config $config
32+
*/
33+
public function __construct(Config $config)
34+
{
35+
$this->config = $config;
36+
}
37+
38+
/**
39+
* Remove index dependency, if it needed, on run reindexing by specifics indexes.
40+
*
41+
* @param Provider $provider
42+
* @param array $dependencies
43+
* @param string $indexerId
44+
* @return array
45+
* @see \Magento\Indexer\Console\Command\IndexerReindexCommand::getIndexers()
46+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
47+
*/
48+
public function afterGetIndexerIdsToRunBefore(Provider $provider, array $dependencies, string $indexerId): array
49+
{
50+
if ($this->isFilteringNeeded($indexerId, CatalogSearchFulltextIndexer::INDEXER_ID)) {
51+
$dependencies = array_diff($dependencies, [CatalogInventoryStockIndexer::INDEXER_ID]);
52+
}
53+
54+
return $dependencies;
55+
}
56+
57+
/**
58+
* Remove index dependency, if it needed, on reindex triggers.
59+
*
60+
* @param Provider $provider
61+
* @param array $dependencies
62+
* @param string $indexerId
63+
* @return array
64+
* @see \Magento\Indexer\Model\Indexer\DependencyDecorator
65+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
66+
*/
67+
public function afterGetIndexerIdsToRunAfter(Provider $provider, array $dependencies, string $indexerId): array
68+
{
69+
if ($this->isFilteringNeeded($indexerId, CatalogInventoryStockIndexer::INDEXER_ID)) {
70+
$dependencies = array_diff($dependencies, [CatalogSearchFulltextIndexer::INDEXER_ID]);
71+
}
72+
73+
return $dependencies;
74+
}
75+
76+
/**
77+
* @param string $currentIndexerId
78+
* @param string $targetIndexerId
79+
* @return bool
80+
*/
81+
private function isFilteringNeeded(string $currentIndexerId, string $targetIndexerId): bool
82+
{
83+
return (!$this->config->isElasticsearchEnabled() && $targetIndexerId === $currentIndexerId);
84+
}
85+
}

0 commit comments

Comments
 (0)