Skip to content

Commit 00f8a8c

Browse files
authored
Merge pull request #5948 from magento-tsg-csl3/2.4-develop-pr34
[TSG-CSL3] For 2.4 (pr34)
2 parents e12a2fd + 52e6554 commit 00f8a8c

File tree

17 files changed

+719
-231
lines changed

17 files changed

+719
-231
lines changed

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

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+
}

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Downloadable\Observer;
79

810
use Magento\Framework\Event\ObserverInterface;
@@ -81,12 +83,14 @@ public function __construct(
8183
*/
8284
public function execute(\Magento\Framework\Event\Observer $observer)
8385
{
86+
/** @var \Magento\Sales\Model\Order\Item $orderItem */
8487
$orderItem = $observer->getEvent()->getItem();
8588
if (!$orderItem->getId()) {
8689
//order not saved in the database
8790
return $this;
8891
}
89-
if ($orderItem->getProductType() != \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
92+
$productType = $orderItem->getRealProductType() ?: $orderItem->getProductType();
93+
if ($productType !== \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
9094
return $this;
9195
}
9296
$product = $orderItem->getProduct();
@@ -112,13 +116,13 @@ public function execute(\Magento\Framework\Event\Observer $observer)
112116
if ($linkIds = $orderItem->getProductOptionByCode('links')) {
113117
$linkPurchased = $this->_createPurchasedModel();
114118
$this->_objectCopyService->copyFieldsetToTarget(
115-
\downloadable_sales_copy_order::class,
119+
'downloadable_sales_copy_order',
116120
'to_downloadable',
117121
$orderItem->getOrder(),
118122
$linkPurchased
119123
);
120124
$this->_objectCopyService->copyFieldsetToTarget(
121-
\downloadable_sales_copy_order_item::class,
125+
'downloadable_sales_copy_order_item',
122126
'to_downloadable',
123127
$orderItem,
124128
$linkPurchased
@@ -131,14 +135,12 @@ public function execute(\Magento\Framework\Event\Observer $observer)
131135
ScopeInterface::SCOPE_STORE
132136
);
133137
$linkPurchased->setLinkSectionTitle($linkSectionTitle)->save();
134-
135138
$linkStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING;
136139
if ($orderStatusToEnableItem == \Magento\Sales\Model\Order\Item::STATUS_PENDING
137140
|| $orderItem->getOrder()->getState() == \Magento\Sales\Model\Order::STATE_COMPLETE
138141
) {
139142
$linkStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE;
140143
}
141-
142144
foreach ($linkIds as $linkId) {
143145
if (isset($links[$linkId])) {
144146
$linkPurchasedItem = $this->_createPurchasedItemModel()->setPurchasedId(
@@ -148,7 +150,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
148150
);
149151

150152
$this->_objectCopyService->copyFieldsetToTarget(
151-
\downloadable_sales_copy_link::class,
153+
'downloadable_sales_copy_link',
152154
'to_purchased',
153155
$links[$linkId],
154156
$linkPurchasedItem

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ public function testSaveDownloadableOrderItem()
176176
$itemMock->expects($this->any())
177177
->method('getProductType')
178178
->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
179+
$itemMock->expects($this->any())
180+
->method('getRealProductType')
181+
->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
179182

180183
$this->orderMock->expects($this->once())
181184
->method('getStoreId')
@@ -311,6 +314,9 @@ public function testSaveDownloadableOrderItemSavedPurchasedLink()
311314
$itemMock->expects($this->any())
312315
->method('getProductType')
313316
->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
317+
$itemMock->expects($this->any())
318+
->method('getRealProductType')
319+
->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
314320

315321
$purchasedLink = $this->getMockBuilder(Purchased::class)
316322
->disableOriginalConstructor()

app/code/Magento/ImportExport/Model/Report/Csv.php

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\ImportExport\Model\Report;
89

@@ -60,22 +61,16 @@ public function __construct(
6061
}
6162

6263
/**
63-
* @param string $originalFileName
64-
* @param ProcessingErrorAggregatorInterface $errorAggregator
65-
* @param bool $writeOnlyErrorItems
66-
* @return string
67-
* @throws \Magento\Framework\Exception\LocalizedException
64+
* @inheritDoc
6865
*/
6966
public function createReport(
7067
$originalFileName,
7168
ProcessingErrorAggregatorInterface $errorAggregator,
7269
$writeOnlyErrorItems = false
7370
) {
74-
$sourceCsv = $this->createSourceCsvModel($originalFileName);
75-
76-
$outputFileName = $this->generateOutputFileName($originalFileName);
77-
$outputCsv = $this->createOutputCsvModel($outputFileName);
71+
$outputCsv = $this->outputCsvFactory->create();
7872

73+
$sourceCsv = $this->createSourceCsvModel($originalFileName);
7974
$columnsName = $sourceCsv->getColNames();
8075
$columnsName[] = self::REPORT_ERROR_COLUMN_NAME;
8176
$outputCsv->setHeaderCols($columnsName);
@@ -88,10 +83,16 @@ public function createReport(
8883
}
8984
}
9085

86+
$directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
87+
$outputFileName = $this->generateOutputFileName($originalFileName);
88+
$directory->writeFile(Import::IMPORT_HISTORY_DIR . $outputFileName, $outputCsv->getContents());
89+
9190
return $outputFileName;
9291
}
9392

9493
/**
94+
* Retrieve error messages
95+
*
9596
* @param int $rowNumber
9697
* @param ProcessingErrorAggregatorInterface $errorAggregator
9798
* @return string
@@ -112,16 +113,21 @@ public function retrieveErrorMessagesByRowNumber($rowNumber, ProcessingErrorAggr
112113
}
113114

114115
/**
116+
* Generate output filename based on source filename
117+
*
115118
* @param string $sourceFile
116119
* @return string
117120
*/
118121
protected function generateOutputFileName($sourceFile)
119122
{
123+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
120124
$fileName = basename($sourceFile, self::ERROR_REPORT_FILE_EXTENSION);
121125
return $fileName . self::ERROR_REPORT_FILE_SUFFIX . self::ERROR_REPORT_FILE_EXTENSION;
122126
}
123127

124128
/**
129+
* Create source CSV model
130+
*
125131
* @param string $sourceFile
126132
* @return \Magento\ImportExport\Model\Import\Source\Csv
127133
*/
@@ -135,18 +141,4 @@ protected function createSourceCsvModel($sourceFile)
135141
]
136142
);
137143
}
138-
139-
/**
140-
* @param string $outputFileName
141-
* @return \Magento\ImportExport\Model\Export\Adapter\Csv
142-
*/
143-
protected function createOutputCsvModel($outputFileName)
144-
{
145-
return $this->outputCsvFactory->create(
146-
[
147-
'destination' => Import::IMPORT_HISTORY_DIR . $outputFileName,
148-
'destinationDirectoryCode' => DirectoryList::VAR_DIR,
149-
]
150-
);
151-
}
152144
}

0 commit comments

Comments
 (0)