File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
app/code/Magento/Persistent Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public function execute(int $websiteId): void
6161 private function processStoreQuotes (StoreInterface $ store ): void
6262 {
6363 $ batchSize = 500 ;
64- $ lastProcessedId = 0 ;
64+ $ lastProcessedId = $ count = 0 ;
6565
6666 while (true ) {
6767 $ quotesToProcess = $ this ->expiredPersistentQuotesCollection
@@ -72,6 +72,7 @@ private function processStoreQuotes(StoreInterface $store): void
7272 }
7373
7474 foreach ($ quotesToProcess as $ quote ) {
75+ $ count ++;
7576 try {
7677 $ this ->quoteRepository ->delete ($ quote );
7778 $ lastProcessedId = (int )$ quote ->getId ();
@@ -82,12 +83,14 @@ private function processStoreQuotes(StoreInterface $store): void
8283 (string )$ e
8384 ));
8485 }
86+ if ($ count % $ batchSize === 0 ) {
87+ $ this ->snapshot ->clear ($ quote );
88+ }
8589 $ quote ->clearInstance ();
8690 unset($ quote );
8791 }
8892
8993 $ quotesToProcess ->clear ();
90- $ this ->snapshot ->clear ();
9194 unset($ quotesToProcess );
9295 }
9396 }
Original file line number Diff line number Diff line change 1616use Magento \Store \Model \StoreManagerInterface ;
1717use Magento \Quote \Model \ResourceModel \Quote \Collection ;
1818use PHPUnit \Framework \MockObject \Exception ;
19+ use PHPUnit \Framework \MockObject \MockObject ;
1920use PHPUnit \Framework \TestCase ;
2021use Psr \Log \LoggerInterface ;
2122use Magento \Store \Api \Data \StoreInterface ;
2223use Magento \Store \Model \Website ;
2324
25+ /**
26+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
27+ */
2428class CleanExpiredPersistentQuotesTest extends TestCase
2529{
2630 /**
@@ -38,6 +42,11 @@ class CleanExpiredPersistentQuotesTest extends TestCase
3842 */
3943 private QuoteRepository $ quoteRepositoryMock ;
4044
45+ /**
46+ * @var MockObject|Snapshot
47+ */
48+ private MockObject |Snapshot $ snapshotMock ;
49+
4150 /**
4251 * @var LoggerInterface
4352 */
You can’t perform that action at this time.
0 commit comments