Skip to content

Commit 6259c84

Browse files
committed
ACP2E-3493: Expired persistent quotes are not cleaned up by a cron job sales_clean_quotes
- Fixed the CR coments.
1 parent 22d1bc9 commit 6259c84

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

app/code/Magento/Persistent/Model/DeleteExpiredQuote.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ public function __construct(
3535
* Delete expired persistent quote for the website
3636
*
3737
* @param int|null $websiteId
38-
* @return $this
39-
* @throws NoSuchEntityException|LocalizedException
38+
* @return void
39+
* @throws LocalizedException
40+
* @throws NoSuchEntityException
4041
*/
41-
public function deleteExpiredQuote($websiteId = null): static
42+
public function deleteExpiredQuote(?int $websiteId): void
4243
{
4344
if ($websiteId === null) {
4445
$websiteId = $this->storeManager->getStore()->getWebsiteId();
@@ -59,7 +60,5 @@ public function deleteExpiredQuote($websiteId = null): static
5960
['store_id in (?)' => $storeIds, 'updated_at < ?' => $expiredBefore, 'is_persistent' => 1]
6061
);
6162
}
62-
63-
return $this;
6463
}
6564
}

app/code/Magento/Persistent/Observer/ClearExpiredCronJobObserver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ClearExpiredCronJobObserver
3333
*
3434
* @var DeleteExpiredQuoteFactory
3535
*/
36-
private DeleteExpiredQuoteFactory $deleteExpiredQuoteFactory;
36+
protected DeleteExpiredQuoteFactory $deleteExpiredQuoteFactory;
3737

3838
/**
3939
* @param CollectionFactory $websiteCollectionFactory
@@ -67,7 +67,7 @@ public function execute(Schedule $schedule)
6767
$deleteExpiredQuote = $this->deleteExpiredQuoteFactory->create();
6868
foreach ($websiteIds as $websiteId) {
6969
$this->_sessionFactory->create()->deleteExpired($websiteId);
70-
$deleteExpiredQuote->deleteExpiredQuote($websiteId);
70+
$deleteExpiredQuote->deleteExpiredQuote((int) $websiteId);
7171
}
7272

7373
return $this;

app/code/Magento/Persistent/Test/Unit/Model/DeleteExpiredQuoteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function testDeleteExpiredQuoteWithNullWebsiteId(): void
141141
);
142142

143143
// Call the method to test with null websiteId
144-
$this->model->deleteExpiredQuote();
144+
$this->model->deleteExpiredQuote(null);
145145
}
146146

147147
/**

0 commit comments

Comments
 (0)