Skip to content

Commit 45a6365

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop Minor Fixes
Accepted Public Pull Requests: - #22421: Spelling correction (by @ansari-krish) - #22420: Correct spelling (by @ravi-chandra3197) - #19993: fixed issue of Backup tool not correctly detecting .maintenance.flag (by @hiren0241) - #22382: Don't skip row on import if image not available. (by @Nazar65) - #22263: Prevented /Magento/Sales/Model/Service/InvoiceService.php incorrectly� (by @ryanpalmerweb) - #22233: [Fixed] Full Tax Summary missing calculation Admin create order (by @niravkrish) - #21711: Purchasing a downloadable product as guest then creating an account on the onepagesuccess step doesn't link product with account (by @Jitheesh) - #20174: Fix issues inserting Widgets with nested WYSIWYGs (by @molovo) - #21816: #21779 Adminhtml textarea field doesn't accept maxlength (by @kisroman) - #21756: Fixes race condition when building merged css/js file during simultaneous requests (by @Ian410) - #21670: Fix getSize method after clearing data collection (by @sergeynezbritskiy) Fixed GitHub Issues: - #19825: Magento 2.3.0: Backup tool not correctly detecting .maintenance.flag (reported by @nexrobr) has been fixed in #19993 by @hiren0241 in 2.3-develop branch Related commits: 1. fd92027 2. 6374f9d 3. 658b5a7 4. 5bc05b2 - #22355: Import product quantity is empty after import (reported by @kevinvuillemin) has been fixed in #22382 by @Nazar65 in 2.3-develop branch Related commits: 1. e949e85 2. bfc82b6 3. b6784b5 - #22246: Programatically created invoices miss items when both simple products and bundled products are mixed in an order (reported by @ryanpalmerweb) has been fixed in #22263 by @ryanpalmerweb in 2.3-develop branch Related commits: 1. ec2c6ca - #21702: Purchasing a downloadable product as guest then creating an account on the onepagesuccess step doesn't link product with account (reported by @crankycyclops) has been fixed in #21711 by @Jitheesh in 2.3-develop branch Related commits: 1. fc1434b 2. 8652bc8 3. 95b1d53 4. 0ade930 - #13409: custom widget with wysiwyg problem on insert widget via pages or blocks (reported by @deagleka) has been fixed in #20174 by @molovo in 2.3-develop branch Related commits: 1. 3bcf0d8 2. d4e0c28 - #19742: Widgets with a WYSIWYG parameter fail when inserting them into a WYSIWYG in a form. (reported by @molovo) has been fixed in #20174 by @molovo in 2.3-develop branch Related commits: 1. 3bcf0d8 2. d4e0c28 - #21779: Adminhtml textarea field doesn't accept maxlength (reported by @rafaelstz) has been fixed in #21816 by @kisroman in 2.3-develop branch Related commits: 1. 1dc63e8 2. 4a0fb16 3. 149294b - #21654: \Magento\Framework\Data\Collection::clear does not clear the result for \Magento\Framework\Data\Collection::getSize (reported by @sergeynezbritskiy) has been fixed in #21670 by @sergeynezbritskiy in 2.3-develop branch Related commits: 1. 2038d7d 2. 71effbe 3. eea6126
2 parents 1d1c2ea + 62c86e4 commit 45a6365

File tree

20 files changed

+272
-88
lines changed

20 files changed

+272
-88
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4335,7 +4335,7 @@ Tests:
43354335
* Fixed order placing with virtual product using Express Checkout
43364336
* Fixed the error during order placement with Recurring profile payment
43374337
* Fixed wrong redirect after customer registration during multishipping checkout
4338-
* Fixed inability to crate shipping labels
4338+
* Fixed inability to create shipping labels
43394339
* Fixed inability to switch language, if the default language is English
43404340
* Fixed an issue with incorrect XML appearing in cache after some actions on the frontend
43414341
* Fixed product export

app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public function execute()
5858
$this->_coreRegistry->register('backup_manager', $backupManager);
5959

6060
if ($this->getRequest()->getParam('maintenance_mode')) {
61-
if (!$this->maintenanceMode->set(true)) {
61+
$this->maintenanceMode->set(true);
62+
63+
if (!$this->maintenanceMode->isOn()) {
6264
$response->setError(
6365
__(
6466
'You need more permissions to activate maintenance mode right now.'

app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
*/
77
namespace Magento\Backup\Controller\Adminhtml\Index;
88

9+
use Magento\Framework\App\Action\HttpPostActionInterface;
910
use Magento\Framework\App\Filesystem\DirectoryList;
1011
use Magento\Framework\Filesystem;
1112

1213
/**
14+
* Backup rollback controller.
15+
*
1316
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1417
*/
15-
class Rollback extends \Magento\Backup\Controller\Adminhtml\Index
18+
class Rollback extends \Magento\Backup\Controller\Adminhtml\Index implements HttpPostActionInterface
1619
{
1720
/**
1821
* Rollback Action
@@ -82,7 +85,9 @@ public function execute()
8285
}
8386

8487
if ($this->getRequest()->getParam('maintenance_mode')) {
85-
if (!$this->maintenanceMode->set(true)) {
88+
$this->maintenanceMode->set(true);
89+
90+
if (!$this->maintenanceMode->isOn()) {
8691
$response->setError(
8792
__(
8893
'You need more permissions to activate maintenance mode right now.'
@@ -122,6 +127,7 @@ public function execute()
122127
$adminSession->destroy();
123128

124129
$response->setRedirectUrl($this->getUrl('*'));
130+
// phpcs:disable Magento2.Exceptions.ThrowCatch
125131
} catch (\Magento\Framework\Backup\Exception\CantLoadSnapshot $e) {
126132
$errorMsg = __('We can\'t find the backup file.');
127133
} catch (\Magento\Framework\Backup\Exception\FtpConnectionFailed $e) {

app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function execute($product, $arguments = [])
206206
}
207207

208208
/**
209-
* Returns media gallery atribute instance
209+
* Returns media gallery attribute instance
210210
*
211211
* @return \Magento\Catalog\Api\Data\ProductAttributeInterface
212212
* @since 101.0.0
@@ -230,6 +230,7 @@ public function getAttribute()
230230
* @return void
231231
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
232232
* @since 101.0.0
233+
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
233234
*/
234235
protected function processDeletedImages($product, array &$images)
235236
{
@@ -400,6 +401,7 @@ protected function getUniqueFileName($file, $forTmp = false)
400401
$destinationFile = $forTmp
401402
? $this->mediaDirectory->getAbsolutePath($this->mediaConfig->getTmpMediaPath($file))
402403
: $this->mediaDirectory->getAbsolutePath($this->mediaConfig->getMediaPath($file));
404+
// phpcs:disable Magento2.Functions.DiscouragedFunction
403405
$destFile = dirname($file) . '/' . FileUploader::getNewFileName($destinationFile);
404406
}
405407

@@ -420,6 +422,7 @@ protected function copyImage($file)
420422
$destinationFile = $this->getUniqueFileName($file);
421423

422424
if (!$this->mediaDirectory->isFile($this->mediaConfig->getMediaPath($file))) {
425+
// phpcs:ignore Magento2.Exceptions.DirectThrow
423426
throw new \Exception();
424427
}
425428

@@ -437,6 +440,7 @@ protected function copyImage($file)
437440
}
438441

439442
return str_replace('\\', '/', $destinationFile);
443+
// phpcs:ignore Magento2.Exceptions.ThrowCatch
440444
} catch (\Exception $e) {
441445
$file = $this->mediaConfig->getMediaPath($file);
442446
throw new \Magento\Framework\Exception\LocalizedException(

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@ protected function _prepareRowForDb(array $rowData)
12471247
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
12481248
* @SuppressWarnings(PHPMD.NPathComplexity)
12491249
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1250+
* phpcs:disable Generic.Metrics.NestingLevel
12501251
*/
12511252
protected function _saveLinks()
12521253
{
@@ -1256,7 +1257,7 @@ protected function _saveLinks()
12561257
$nextLinkId = $this->_resourceHelper->getNextAutoincrement($mainTable);
12571258

12581259
// pre-load 'position' attributes ID for each link type once
1259-
foreach ($this->_linkNameToId as $linkName => $linkId) {
1260+
foreach ($this->_linkNameToId as $linkId) {
12601261
$select = $this->_connection->select()->from(
12611262
$resource->getTable('catalog_product_link_attribute'),
12621263
['id' => 'product_link_attribute_id']
@@ -1374,6 +1375,7 @@ protected function _saveLinks()
13741375
}
13751376
return $this;
13761377
}
1378+
// phpcs:enable
13771379

13781380
/**
13791381
* Save product attributes.
@@ -1608,6 +1610,7 @@ public function getImagesFromRow(array $rowData)
16081610
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
16091611
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
16101612
* @throws LocalizedException
1613+
* phpcs:disable Generic.Metrics.NestingLevel
16111614
*/
16121615
protected function _saveProducts()
16131616
{
@@ -1798,7 +1801,13 @@ protected function _saveProducts()
17981801
$uploadedImages[$columnImage] = $uploadedFile;
17991802
} else {
18001803
unset($rowData[$column]);
1801-
$this->skipRow($rowNum, ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE);
1804+
$this->addRowError(
1805+
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE,
1806+
$rowNum,
1807+
null,
1808+
null,
1809+
ProcessingError::ERROR_LEVEL_NOT_CRITICAL
1810+
);
18021811
}
18031812
} else {
18041813
$uploadedFile = $uploadedImages[$columnImage];
@@ -1974,6 +1983,7 @@ protected function _saveProducts()
19741983

19751984
return $this;
19761985
}
1986+
// phpcs:enable
19771987

19781988
/**
19791989
* Prepare array with image states (visible or hidden from product page)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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\Downloadable\Observer;
9+
10+
use Magento\Framework\Event\ObserverInterface;
11+
12+
/**
13+
* Assign Downloadable links to customer created after issuing guest order.
14+
*/
15+
class UpdateLinkPurchasedObserver implements ObserverInterface
16+
{
17+
/**
18+
* Core store config
19+
* @var \Magento\Framework\App\Config\ScopeConfigInterface
20+
*/
21+
private $scopeConfig;
22+
23+
/**
24+
* @var \Magento\Downloadable\Model\ResourceModel\Link\Purchased\CollectionFactory
25+
*/
26+
private $purchasedFactory;
27+
28+
/**
29+
* @var \Magento\Framework\DataObject\Copy
30+
*/
31+
private $objectCopyService;
32+
33+
/**
34+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
35+
* @param \Magento\Downloadable\Model\ResourceModel\Link\Purchased\CollectionFactory $purchasedFactory
36+
* @param \Magento\Framework\DataObject\Copy $objectCopyService
37+
*/
38+
public function __construct(
39+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
40+
\Magento\Downloadable\Model\ResourceModel\Link\Purchased\CollectionFactory $purchasedFactory,
41+
\Magento\Framework\DataObject\Copy $objectCopyService
42+
) {
43+
$this->scopeConfig = $scopeConfig;
44+
$this->purchasedFactory = $purchasedFactory;
45+
$this->objectCopyService = $objectCopyService;
46+
}
47+
48+
/**
49+
* Re-save order data after order update.
50+
*
51+
* @param \Magento\Framework\Event\Observer $observer
52+
* @return $this
53+
*/
54+
public function execute(\Magento\Framework\Event\Observer $observer)
55+
{
56+
$order = $observer->getEvent()->getOrder();
57+
58+
if (!$order->getId()) {
59+
//order not saved in the database
60+
return $this;
61+
}
62+
63+
$purchasedLinks = $this->purchasedFactory->create()->addFieldToFilter(
64+
'order_id',
65+
['eq' => $order->getId()]
66+
);
67+
68+
foreach ($purchasedLinks as $linkPurchased) {
69+
$this->objectCopyService->copyFieldsetToTarget(
70+
\downloadable_sales_copy_order::class,
71+
'to_downloadable',
72+
$order,
73+
$linkPurchased
74+
);
75+
$linkPurchased->save();
76+
}
77+
78+
return $this;
79+
}
80+
}

app/code/Magento/Downloadable/etc/events.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</event>
1212
<event name="sales_order_save_after">
1313
<observer name="downloadable_observer" instance="Magento\Downloadable\Observer\SetLinkStatusObserver" />
14+
<observer name="downloadable_observer_assign_customer" instance="Magento\Downloadable\Observer\UpdateLinkPurchasedObserver" />
1415
</event>
1516
<event name="sales_model_service_quote_submit_success">
1617
<observer name="checkout_type_onepage_save_order_after" instance="Magento\Downloadable\Observer\SetHasDownloadableProductsObserver" />

app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/**
1717
* Entity/Attribute/Model - collection abstract
1818
*
19+
* phpcs:disable Magento2.Classes.AbstractApi
1920
* @api
2021
* @SuppressWarnings(PHPMD.TooManyFields)
2122
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
@@ -188,6 +189,7 @@ public function __construct(
188189
* Initialize collection
189190
*
190191
* @return void
192+
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
191193
*/
192194
protected function _construct()
193195
{
@@ -298,7 +300,7 @@ public function getResource()
298300
/**
299301
* Set template object for the collection
300302
*
301-
* @param \Magento\Framework\DataObject $object
303+
* @param \Magento\Framework\DataObject $object
302304
* @return $this
303305
*/
304306
public function setObject($object = null)
@@ -395,7 +397,7 @@ public function addAttributeToFilter($attribute, $condition = null, $joinType =
395397

396398
if (!empty($conditionSql)) {
397399
$this->getSelect()->where($conditionSql, null, \Magento\Framework\DB\Select::TYPE_CONDITION);
398-
$this->invalidateSize();
400+
$this->_totalRecords = null;
399401
} else {
400402
throw new \Magento\Framework\Exception\LocalizedException(
401403
__('Invalid attribute identifier for filter (%1)', get_class($attribute))
@@ -1371,8 +1373,8 @@ protected function _getAttributeFieldName($attributeCode)
13711373
/**
13721374
* Add attribute value table to the join if it wasn't added previously
13731375
*
1374-
* @param string $attributeCode
1375-
* @param string $joinType inner|left
1376+
* @param string $attributeCode
1377+
* @param string $joinType inner|left
13761378
* @return $this
13771379
* @throws LocalizedException
13781380
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -1466,12 +1468,12 @@ protected function getEntityPkName(\Magento\Eav\Model\Entity\AbstractEntity $ent
14661468
/**
14671469
* Adding join statement to collection select instance
14681470
*
1469-
* @param string $method
1470-
* @param object $attribute
1471-
* @param string $tableAlias
1472-
* @param array $condition
1473-
* @param string $fieldCode
1474-
* @param string $fieldAlias
1471+
* @param string $method
1472+
* @param object $attribute
1473+
* @param string $tableAlias
1474+
* @param array $condition
1475+
* @param string $fieldCode
1476+
* @param string $fieldAlias
14751477
* @return $this
14761478
*/
14771479
protected function _joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias)
@@ -1719,16 +1721,4 @@ public function removeAllFieldsFromSelect()
17191721
{
17201722
return $this->removeAttributeToSelect();
17211723
}
1722-
1723-
/**
1724-
* Invalidates "Total Records Count".
1725-
* Invalidates saved "Total Records Count" attribute with last counting,
1726-
* so a next calling of method getSize() will query new total records count.
1727-
*
1728-
* @return void
1729-
*/
1730-
private function invalidateSize(): void
1731-
{
1732-
$this->_totalRecords = null;
1733-
}
17341724
}

app/code/Magento/Sales/Model/Service/InvoiceService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public function setVoid($id)
149149
*/
150150
public function prepareInvoice(Order $order, array $qtys = [])
151151
{
152+
$isQtysEmpty = empty($qtys);
152153
$invoice = $this->orderConverter->toInvoice($order);
153154
$totalQty = 0;
154155
$qtys = $this->prepareItemsQty($order, $qtys);
@@ -161,7 +162,7 @@ public function prepareInvoice(Order $order, array $qtys = [])
161162
$qty = (double) $qtys[$orderItem->getId()];
162163
} elseif ($orderItem->isDummy()) {
163164
$qty = $orderItem->getQtyOrdered() ? $orderItem->getQtyOrdered() : 1;
164-
} elseif (empty($qtys)) {
165+
} elseif ($isQtysEmpty) {
165166
$qty = $orderItem->getQtyToInvoice();
166167
} else {
167168
$qty = 0;

app/code/Magento/Sales/view/adminhtml/templates/order/create/totals/tax.phtml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ $taxAmount = $block->getTotal()->getValue();
3333
<?php $percent = $info['percent']; ?>
3434
<?php $amount = $info['amount']; ?>
3535
<?php $rates = $info['rates']; ?>
36-
<?php $isFirst = 1; ?>
3736

3837
<?php foreach ($rates as $rate): ?>
3938
<tr class="summary-details-<?= /* @escapeNotVerified */ $taxIter ?> summary-details<?php if ($isTop): echo ' summary-details-first'; endif; ?>" style="display:none;">
@@ -44,13 +43,10 @@ $taxAmount = $block->getTotal()->getValue();
4443
<?php endif; ?>
4544
<br />
4645
</td>
47-
<?php if ($isFirst): ?>
48-
<td style="<?= /* @escapeNotVerified */ $block->getTotal()->getStyle() ?>" class="admin__total-amount" rowspan="<?= count($rates) ?>">
49-
<?= /* @escapeNotVerified */ $block->formatPrice($amount) ?>
50-
</td>
51-
<?php endif; ?>
46+
<td style="<?= /* @escapeNotVerified */ $block->getTotal()->getStyle() ?>" class="admin__total-amount">
47+
<?= /* @escapeNotVerified */ $block->formatPrice(($amount*(float)$rate['percent'])/$percent) ?>
48+
</td>
5249
</tr>
53-
<?php $isFirst = 0; ?>
5450
<?php $isTop = 0; ?>
5551
<?php endforeach; ?>
5652
<?php endforeach; ?>

0 commit comments

Comments
 (0)