Skip to content

Commit 77294bf

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #19945: [Backport] issue 18941 (by @Nazar65) - #19911: [Backport] fixed store wise product filter issue (by @shikhamis11) - #18912: [Backport] Fixed subscribe to newsletter if you already have an account issue (by @ravi-chandra3197) - #19280: [BackPort] resolve typos and correct variable names (by @viral-wagento) - #19199: [Backport][2.2] Made logo clickable on home page (by @gwharton) - #19693: [Backport] Cancel expired orders using OrderManagementInterface (by @JeroenVanLeusden) - #19690: [Backport] Additional Cache Management title (by @thomas-blackbird) Fixed GitHub Issues: - #18941: Calling getCurrentUrl on Store will wrongly add "___store" parameter (reported by @LucaGallinari) has been fixed in #19945 by @Nazar65 in 2.2-develop branch Related commits: 1. 20a81dc - #18374: Unable to get product attribute value for store-view scope type in product collection loaded for a specific store. (reported by @milindsingh) has been fixed in #19911 by @shikhamis11 in 2.2-develop branch Related commits: 1. 3fad6a7 2. e9e1db6 - #8952: You can't subscribe to newsletter if you already have an account (reported by @loomdecor) has been fixed in #18912 by @ravi-chandra3197 in 2.2-develop branch Related commits: 1. b1fc4a7 - #19142: Home page store loge should be clickable to reload page (reported by @tomekjordan) has been fixed in #19199 by @gwharton in 2.2-develop branch Related commits: 1. bd3cb9b 2. 2ad7fd6
2 parents 5cda5e0 + ffbed00 commit 77294bf

File tree

13 files changed

+158
-47
lines changed

13 files changed

+158
-47
lines changed

app/code/Magento/Backend/view/adminhtml/templates/system/cache/additional.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ $permissions = $block->getData('permissions');
1111
?>
1212
<?php if ($permissions && $permissions->hasAccessToAdditionalActions()): ?>
1313
<div class="additional-cache-management">
14+
<h2>
15+
<span><?= $block->escapeHtml(__('Additional Cache Management')); ?></span>
16+
</h2>
1417
<?php if ($permissions->hasAccessToFlushCatalogImages()): ?>
15-
<h2>
16-
<span><?= $block->escapeHtml(__('Additional Cache Management')); ?></span>
17-
</h2>
1818
<p>
1919
<button onclick="setLocation('<?= $block->escapeJs($block->getCleanImagesUrl()); ?>')" type="button">
2020
<?= $block->escapeHtml(__('Flush Catalog Images Cache')); ?>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ public function addAttributeToFilter($attribute, $condition = null, $joinType =
394394
*/
395395
public function addFieldToFilter($attribute, $condition = null)
396396
{
397-
return $this->addAttributeToFilter($attribute, $condition);
397+
return $this->addAttributeToFilter($attribute, $condition, 'left');
398398
}
399399

400400
/**

app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ public function __construct(
7777
protected function validateEmailAvailable($email)
7878
{
7979
$websiteId = $this->_storeManager->getStore()->getWebsiteId();
80-
if ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
80+
if ($this->_customerSession->isLoggedIn()
81+
&& ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
8182
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId)
82-
) {
83+
)) {
8384
throw new LocalizedException(
8485
__('This email address is already assigned to another user.')
8586
);

app/code/Magento/Sales/Model/CronJob/CleanExpiredOrders.php

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

10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Sales\Api\OrderManagementInterface;
12+
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
813
use Magento\Store\Model\StoresConfig;
914
use Magento\Sales\Model\Order;
1015

16+
/**
17+
* Class that provides functionality of cleaning expired quotes by cron
18+
*/
1119
class CleanExpiredOrders
1220
{
1321
/**
@@ -16,20 +24,28 @@ class CleanExpiredOrders
1624
protected $storesConfig;
1725

1826
/**
19-
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
27+
* @var CollectionFactory
2028
*/
2129
protected $orderCollectionFactory;
2230

31+
/**
32+
* @var OrderManagementInterface
33+
*/
34+
private $orderManagement;
35+
2336
/**
2437
* @param StoresConfig $storesConfig
25-
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $collectionFactory
38+
* @param CollectionFactory $collectionFactory
39+
* @param OrderManagementInterface|null $orderManagement
2640
*/
2741
public function __construct(
2842
StoresConfig $storesConfig,
29-
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $collectionFactory
43+
CollectionFactory $collectionFactory,
44+
OrderManagementInterface $orderManagement = null
3045
) {
3146
$this->storesConfig = $storesConfig;
3247
$this->orderCollectionFactory = $collectionFactory;
48+
$this->orderManagement = $orderManagement ?: ObjectManager::getInstance()->get(OrderManagementInterface::class);
3349
}
3450

3551
/**
@@ -48,8 +64,10 @@ public function execute()
4864
$orders->getSelect()->where(
4965
new \Zend_Db_Expr('TIME_TO_SEC(TIMEDIFF(CURRENT_TIMESTAMP, `updated_at`)) >= ' . $lifetime * 60)
5066
);
51-
$orders->walk('cancel');
52-
$orders->walk('save');
67+
68+
foreach ($orders->getAllIds() as $entityId) {
69+
$this->orderManagement->cancel((int) $entityId);
70+
}
5371
}
5472
}
5573
}

app/code/Magento/Sales/Model/Order.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,8 @@ private function canCreditmemoForZeroTotalRefunded(float $totalRefunded): bool
665665
$isRefundZero = abs($totalRefunded) < .0001;
666666
// Case when Adjustment Fee (adjustment_negative) has been used for first creditmemo
667667
$hasAdjustmentFee = abs($totalRefunded - $this->getAdjustmentNegative()) < .0001;
668-
$hasActinFlag = $this->getActionFlag(self::ACTION_FLAG_EDIT) === false;
669-
if ($isRefundZero || $hasAdjustmentFee || $hasActinFlag) {
668+
$hasActionFlag = $this->getActionFlag(self::ACTION_FLAG_EDIT) === false;
669+
if ($isRefundZero || $hasAdjustmentFee || $hasActionFlag) {
670670
return false;
671671
}
672672

@@ -682,15 +682,15 @@ private function canCreditmemoForZeroTotalRefunded(float $totalRefunded): bool
682682
private function canCreditmemoForZeroTotal(float $totalRefunded): bool
683683
{
684684
$totalPaid = $this->getTotalPaid();
685-
//check if total paid is less than grandtotal
685+
//check if total paid is less than grand total
686686
$checkAmtTotalPaid = $totalPaid <= $this->getGrandTotal();
687687
//case when amount is due for invoice
688-
$dueAmountCondition = $this->canInvoice() && $checkAmtTotalPaid;
688+
$hasDueAmount = $this->canInvoice() && $checkAmtTotalPaid;
689689
//case when paid amount is refunded and order has creditmemo created
690690
$creditmemos = ($this->getCreditmemosCollection() === false) ?
691691
true : (count($this->getCreditmemosCollection()) > 0);
692692
$paidAmtIsRefunded = $this->getTotalRefunded() == $totalPaid && $creditmemos;
693-
if (($dueAmountCondition || $paidAmtIsRefunded)
693+
if (($hasDueAmount || $paidAmtIsRefunded)
694694
|| (!$checkAmtTotalPaid && abs($totalRefunded - $this->getAdjustmentNegative()) < .0001)
695695
) {
696696
return false;

app/code/Magento/Sales/Test/Unit/Model/CronJob/CleanExpiredOrdersTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class CleanExpiredOrdersTest extends \PHPUnit\Framework\TestCase
2626
*/
2727
protected $orderCollectionMock;
2828

29+
/**
30+
* @var \PHPUnit_Framework_MockObject_MockObject
31+
*/
32+
private $orderManagementMock;
33+
2934
/**
3035
* @var ObjectManager
3136
*/
@@ -44,10 +49,12 @@ protected function setUp()
4449
['create']
4550
);
4651
$this->orderCollectionMock = $this->createMock(\Magento\Sales\Model\ResourceModel\Order\Collection::class);
52+
$this->orderManagementMock = $this->createMock(\Magento\Sales\Api\OrderManagementInterface::class);
4753

4854
$this->model = new CleanExpiredOrders(
4955
$this->storesConfigMock,
50-
$this->collectionFactoryMock
56+
$this->collectionFactoryMock,
57+
$this->orderManagementMock
5158
);
5259
}
5360

@@ -64,8 +71,11 @@ public function testExecute()
6471
$this->collectionFactoryMock->expects($this->exactly(2))
6572
->method('create')
6673
->willReturn($this->orderCollectionMock);
74+
$this->orderCollectionMock->expects($this->exactly(2))
75+
->method('getAllIds')
76+
->willReturn([1, 2]);
6777
$this->orderCollectionMock->expects($this->exactly(4))->method('addFieldToFilter');
68-
$this->orderCollectionMock->expects($this->exactly(4))->method('walk');
78+
$this->orderManagementMock->expects($this->exactly(4))->method('cancel');
6979

7080
$selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
7181
$selectMock->expects($this->exactly(2))->method('where')->willReturnSelf();
@@ -92,14 +102,18 @@ public function testExecuteWithException()
92102
$this->collectionFactoryMock->expects($this->once())
93103
->method('create')
94104
->willReturn($this->orderCollectionMock);
105+
$this->orderCollectionMock->expects($this->once())
106+
->method('getAllIds')
107+
->willReturn([1]);
95108
$this->orderCollectionMock->expects($this->exactly(2))->method('addFieldToFilter');
109+
$this->orderManagementMock->expects($this->once())->method('cancel');
96110

97111
$selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
98112
$selectMock->expects($this->once())->method('where')->willReturnSelf();
99113
$this->orderCollectionMock->expects($this->once())->method('getSelect')->willReturn($selectMock);
100114

101-
$this->orderCollectionMock->expects($this->once())
102-
->method('walk')
115+
$this->orderManagementMock->expects($this->once())
116+
->method('cancel')
103117
->willThrowException(new \Exception($exceptionMessage));
104118

105119
$this->model->execute();

app/code/Magento/Sales/i18n/en_US.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,3 +796,5 @@ Created,Created
796796
"PDF Creditmemos","PDF Creditmemos"
797797
Refunds,Refunds
798798
"Shipment with requested ID %1 doesn't correspond with Order with requested ID %2.","Shipment with requested ID %1 doesn't correspond with Order with requested ID %2."
799+
"Allow Zero GrandTotal for Creditmemo","Allow Zero GrandTotal for Creditmemo"
800+
"Allow Zero GrandTotal","Allow Zero GrandTotal"

app/code/Magento/Store/Test/Unit/Url/Plugin/RouteParamsResolverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function testBeforeSetRouteParamsScopeInParams()
8080
$routeParamsResolverMock->expects($this->once())->method('setScope')->with($storeCode);
8181
$routeParamsResolverMock->expects($this->once())->method('getScope')->willReturn($storeCode);
8282

83-
$this->queryParamsResolverMock->expects($this->never())->method('setQueryParam');
83+
$this->queryParamsResolverMock->expects($this->any())->method('setQueryParam');
8484

8585
$this->model->beforeSetRouteParams(
8686
$routeParamsResolverMock,
@@ -113,7 +113,7 @@ public function testBeforeSetRouteParamsScopeUseStoreInUrl()
113113
$routeParamsResolverMock->expects($this->once())->method('setScope')->with($storeCode);
114114
$routeParamsResolverMock->expects($this->once())->method('getScope')->willReturn($storeCode);
115115

116-
$this->queryParamsResolverMock->expects($this->once())->method('setQueryParam')->with('___store', $storeCode);
116+
$this->queryParamsResolverMock->expects($this->never())->method('setQueryParam')->with('___store', $storeCode);
117117

118118
$this->model->beforeSetRouteParams(
119119
$routeParamsResolverMock,
@@ -178,7 +178,7 @@ public function testBeforeSetRouteParamsNoScopeInParams()
178178
$routeParamsResolverMock->expects($this->never())->method('setScope');
179179
$routeParamsResolverMock->expects($this->once())->method('getScope')->willReturn(false);
180180

181-
$this->queryParamsResolverMock->expects($this->once())->method('setQueryParam')->with('___store', $storeCode);
181+
$this->queryParamsResolverMock->expects($this->never())->method('setQueryParam')->with('___store', $storeCode);
182182

183183
$this->model->beforeSetRouteParams(
184184
$routeParamsResolverMock,

app/code/Magento/Store/Url/Plugin/RouteParamsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function beforeSetRouteParams(
7878
$storeCode
7979
);
8080

81-
if ($useStoreInUrl && !$this->storeManager->hasSingleStore()) {
81+
if (!$useStoreInUrl && !$this->storeManager->hasSingleStore()) {
8282
$this->queryParamsResolver->setQueryParam('___store', $storeCode);
8383
}
8484
}

app/code/Magento/Theme/Block/Html/Header/Logo.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public function __construct(
4343
/**
4444
* Check if current url is url for home page
4545
*
46+
* @deprecated This function is no longer used. It was previously used by
47+
* Magento/Theme/view/frontend/templates/html/header/logo.phtml
48+
* to check if the logo should be clickable on the homepage.
49+
*
4650
* @return bool
4751
*/
4852
public function isHomePage()

0 commit comments

Comments
 (0)