Skip to content

Commit c716884

Browse files
committed
Merge branch '2.4-develop' of github.com:magento/magento2 into 1703-deleted-tags-not-removed
2 parents b2b45e6 + 49c6846 commit c716884

File tree

146 files changed

+4769
-444
lines changed

Some content is hidden

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

146 files changed

+4769
-444
lines changed

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ public function build(array $args, bool $includeAggregation): SearchCriteriaInte
101101
}
102102

103103
if (!$searchCriteria->getSortOrders()) {
104-
$this->addDefaultSortOrder($searchCriteria, $isSearch);
104+
$this->addDefaultSortOrder($searchCriteria, $args, $isSearch);
105105
}
106106

107+
$this->addEntityIdSort($searchCriteria, $isSearch);
107108
$this->addVisibilityFilter($searchCriteria, $isSearch, !empty($args['filter']));
108109

109110
$searchCriteria->setCurrentPage($args['currentPage']);
@@ -132,6 +133,25 @@ private function addVisibilityFilter(SearchCriteriaInterface $searchCriteria, bo
132133
$this->addFilter($searchCriteria, 'visibility', $visibilityIds, 'in');
133134
}
134135

136+
/**
137+
* Add sort by Entity ID
138+
*
139+
* @param SearchCriteriaInterface $searchCriteria
140+
* @param bool $isSearch
141+
*/
142+
private function addEntityIdSort(SearchCriteriaInterface $searchCriteria, bool $isSearch): void
143+
{
144+
if ($isSearch) {
145+
return;
146+
}
147+
$sortOrderArray = $searchCriteria->getSortOrders();
148+
$sortOrderArray[] = $this->sortOrderBuilder
149+
->setField('_id')
150+
->setDirection(SortOrder::SORT_DESC)
151+
->create();
152+
$searchCriteria->setSortOrders($sortOrderArray);
153+
}
154+
135155
/**
136156
* Prepare price aggregation algorithm
137157
*
@@ -179,18 +199,32 @@ private function addFilter(
179199
* Sort by relevance DESC by default
180200
*
181201
* @param SearchCriteriaInterface $searchCriteria
202+
* @param array $args
182203
* @param bool $isSearch
183204
*/
184-
private function addDefaultSortOrder(SearchCriteriaInterface $searchCriteria, $isSearch = false): void
205+
private function addDefaultSortOrder(SearchCriteriaInterface $searchCriteria, array $args, $isSearch = false): void
185206
{
186-
$sortField = $isSearch ? 'relevance' : EavAttributeInterface::POSITION;
187-
$sortDirection = $isSearch ? SortOrder::SORT_DESC : SortOrder::SORT_ASC;
188-
$defaultSortOrder = $this->sortOrderBuilder
189-
->setField($sortField)
190-
->setDirection($sortDirection)
191-
->create();
207+
$defaultSortOrder = [];
208+
if ($isSearch) {
209+
$defaultSortOrder[] = $this->sortOrderBuilder
210+
->setField('relevance')
211+
->setDirection(SortOrder::SORT_DESC)
212+
->create();
213+
} else {
214+
$categoryIdFilter = isset($args['filter']['category_id']) ? $args['filter']['category_id'] : false;
215+
if ($categoryIdFilter) {
216+
if (!is_array($categoryIdFilter[array_key_first($categoryIdFilter)])
217+
|| count($categoryIdFilter[array_key_first($categoryIdFilter)]) <= 1
218+
) {
219+
$defaultSortOrder[] = $this->sortOrderBuilder
220+
->setField(EavAttributeInterface::POSITION)
221+
->setDirection(SortOrder::SORT_ASC)
222+
->create();
223+
}
224+
}
225+
}
192226

193-
$searchCriteria->setSortOrders([$defaultSortOrder]);
227+
$searchCriteria->setSortOrders($defaultSortOrder);
194228
}
195229

196230
/**

app/code/Magento/CatalogGraphQl/Model/Category/CategoryFilter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\Exception\InputException;
1414
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1515
use Magento\Framework\GraphQl\Query\Resolver\Argument\SearchCriteria\ArgumentApplier\Filter;
16+
use Magento\Framework\GraphQl\Query\Resolver\Argument\SearchCriteria\ArgumentApplier\Sort;
1617
use Magento\Search\Model\Query;
1718
use Magento\Store\Api\Data\StoreInterface;
1819
use Magento\Store\Model\ScopeInterface;
@@ -71,6 +72,7 @@ public function getResult(array $criteria, StoreInterface $store)
7172
$categoryIds = [];
7273
$criteria[Filter::ARGUMENT_NAME] = $this->formatMatchFilters($criteria['filters'], $store);
7374
$criteria[Filter::ARGUMENT_NAME][CategoryInterface::KEY_IS_ACTIVE] = ['eq' => 1];
75+
$criteria[Sort::ARGUMENT_NAME][CategoryInterface::KEY_POSITION] = ['ASC'];
7476
$searchCriteria = $this->searchCriteriaBuilder->build('categoryList', $criteria);
7577
$pageSize = $criteria['pageSize'] ?? 20;
7678
$currentPage = $criteria['currentPage'] ?? 1;

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/ProductSearch.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ private function getSortOrderArray(SearchCriteriaInterface $searchCriteria)
153153
$sortOrders = $searchCriteria->getSortOrders();
154154
if (is_array($sortOrders)) {
155155
foreach ($sortOrders as $sortOrder) {
156+
// I am replacing _id with entity_id because in ElasticSearch _id is required for sorting by ID.
157+
// Where as entity_id is required when using ID as the sort in $collection->load();.
158+
// @see \Magento\CatalogGraphQl\Model\Resolver\Products\Query\Search::getResult
159+
if ($sortOrder->getField() === '_id') {
160+
$sortOrder->setField('entity_id');
161+
}
156162
$ordersArray[$sortOrder->getField()] = $sortOrder->getDirection();
157163
}
158164
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/Search.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\CatalogGraphQl\Model\Resolver\Products\SearchResult;
1313
use Magento\CatalogGraphQl\Model\Resolver\Products\SearchResultFactory;
1414
use Magento\Framework\Api\Search\SearchCriteriaInterface;
15+
use Magento\Framework\Exception\InputException;
1516
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1617
use Magento\GraphQl\Model\Query\ContextInterface;
1718
use Magento\Search\Api\SearchInterface;
@@ -83,6 +84,7 @@ public function __construct(
8384
* @param ResolveInfo $info
8485
* @param ContextInterface $context
8586
* @return SearchResult
87+
* @throws InputException
8688
*/
8789
public function getResult(
8890
array $args,
@@ -103,7 +105,12 @@ public function getResult(
103105
//Address limitations of sort and pagination on search API apply original pagination from GQL query
104106
$searchCriteria->setPageSize($realPageSize);
105107
$searchCriteria->setCurrentPage($realCurrentPage);
106-
$searchResults = $this->productsProvider->getList($searchCriteria, $itemsResults, $queryFields, $context);
108+
$searchResults = $this->productsProvider->getList(
109+
$searchCriteria,
110+
$itemsResults,
111+
$queryFields,
112+
$context
113+
);
107114

108115
$totalPages = $realPageSize ? ((int)ceil($searchResults->getTotalCount() / $realPageSize)) : 0;
109116

app/code/Magento/Checkout/view/frontend/web/js/region-updater.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ define([
157157
regionInput = $(this.options.regionInputId),
158158
postcode = $(this.options.postcodeId),
159159
label = regionList.parent().siblings('label'),
160-
container = regionList.parents('div.field');
160+
container = regionList.parents('div.field'),
161+
regionsEntries,
162+
regionId,
163+
regionData;
161164

162165
this._clearError();
163166
this._checkRegionRequired(country);
@@ -168,8 +171,14 @@ define([
168171
// Populate state/province dropdown list if available or use input box
169172
if (this.options.regionJson[country]) {
170173
this._removeSelectOptions(regionList);
171-
$.each(this.options.regionJson[country], $.proxy(function (key, value) {
172-
this._renderSelectOption(regionList, key, value);
174+
regionsEntries = _.pairs(this.options.regionJson[country]);
175+
regionsEntries.sort(function (a, b) {
176+
return a[1].name > b[1].name ? 1 : -1;
177+
});
178+
$.each(regionsEntries, $.proxy(function (key, value) {
179+
regionId = value[0];
180+
regionData = value[1];
181+
this._renderSelectOption(regionList, regionId, regionData);
173182
}, this));
174183

175184
if (this.currentRegionOption) {
@@ -193,7 +202,7 @@ define([
193202
regionList.hide();
194203
container.hide();
195204
} else {
196-
regionList.show();
205+
regionList.removeAttr('disabled').show();
197206
}
198207
}
199208

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontAssertOnCustomerLoginPageActionGroup">
12+
<annotations>
13+
<description>Assert on the Storefront Customer Sign-In page.</description>
14+
</annotations>
15+
16+
<seeInCurrentUrl url="{{StorefrontCustomerSignInPage.url}}" stepKey="seeOnSignInPage"/>
17+
</actionGroup>
18+
</actionGroups>

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/Deploy/Process/Queue.php

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Queue
2929
/**
3030
* Default max execution time
3131
*/
32-
const DEFAULT_MAX_EXEC_TIME = 400;
32+
const DEFAULT_MAX_EXEC_TIME = 900;
3333

3434
/**
3535
* @var array
@@ -96,6 +96,11 @@ class Queue
9696
*/
9797
private $lastJobStarted = 0;
9898

99+
/**
100+
* @var int
101+
*/
102+
private $logDelay;
103+
99104
/**
100105
* @param AppState $appState
101106
* @param LocaleResolver $localeResolver
@@ -157,11 +162,12 @@ public function getPackages()
157162
* Process jobs
158163
*
159164
* @return int
165+
* @throws TimeoutException
160166
*/
161167
public function process()
162168
{
163169
$returnStatus = 0;
164-
$logDelay = 10;
170+
$this->logDelay = 10;
165171
$this->start = $this->lastJobStarted = time();
166172
$packages = $this->packages;
167173
while (count($packages) && $this->checkTimeout()) {
@@ -170,13 +176,7 @@ public function process()
170176
$this->assertAndExecute($name, $packages, $packageJob);
171177
}
172178

173-
// refresh current status in console once in 10 iterations (once in 5 sec)
174-
if ($logDelay >= 10) {
175-
$this->logger->info('.');
176-
$logDelay = 0;
177-
} else {
178-
$logDelay++;
179-
}
179+
$this->refreshStatus();
180180

181181
if ($this->isCanBeParalleled()) {
182182
// in parallel mode sleep before trying to check status and run new jobs
@@ -193,9 +193,28 @@ public function process()
193193

194194
$this->awaitForAllProcesses();
195195

196+
if (!empty($packages)) {
197+
throw new TimeoutException('Not all packages are deployed.');
198+
}
199+
196200
return $returnStatus;
197201
}
198202

203+
/**
204+
* Refresh current status in console once in 10 iterations (once in 5 sec)
205+
*
206+
* @return void
207+
*/
208+
private function refreshStatus(): void
209+
{
210+
if ($this->logDelay >= 10) {
211+
$this->logger->info('.');
212+
$this->logDelay = 0;
213+
} else {
214+
$this->logDelay++;
215+
}
216+
}
217+
199218
/**
200219
* Check that all depended packages deployed and execute
201220
*
@@ -204,7 +223,7 @@ public function process()
204223
* @param array $packageJob
205224
* @return void
206225
*/
207-
private function assertAndExecute($name, array & $packages, array $packageJob)
226+
private function assertAndExecute($name, array &$packages, array $packageJob)
208227
{
209228
/** @var Package $package */
210229
$package = $packageJob['package'];
@@ -256,21 +275,14 @@ private function executePackage(Package $package, string $name, array &$packages
256275
*/
257276
private function awaitForAllProcesses()
258277
{
259-
$logDelay = 10;
260278
while ($this->inProgress && $this->checkTimeout()) {
261279
foreach ($this->inProgress as $name => $package) {
262280
if ($this->isDeployed($package)) {
263281
unset($this->inProgress[$name]);
264282
}
265283
}
266284

267-
// refresh current status in console once in 10 iterations (once in 5 sec)
268-
if ($logDelay >= 10) {
269-
$this->logger->info('.');
270-
$logDelay = 0;
271-
} else {
272-
$logDelay++;
273-
}
285+
$this->refreshStatus();
274286

275287
// sleep before checking parallel jobs status
276288
// phpcs:ignore Magento2.Functions.DiscouragedFunction
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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\Deploy\Process;
9+
10+
/**
11+
* Exception is thrown if deploy process is finished due to timeout.
12+
*/
13+
class TimeoutException extends \RuntimeException
14+
{
15+
}

0 commit comments

Comments
 (0)