Skip to content

Commit 9fad9e5

Browse files
author
Anna Bukatar
committed
ACP2E-2811: Reindexing Catalog Rule Product Indexer throws SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
1 parent 7e0fc6b commit 9fad9e5

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProduct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function execute(Rule $rule, $batchCount, $useAdditionalTable = false)
146146
'sort_order' => $sortOrder,
147147
];
148148

149-
if (count($rows) === $batchCount) {
149+
if (count($rows) === (int) $batchCount) {
150150
$connection->insertMultiple($indexTable, $rows);
151151
$rows = [];
152152
}

app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,28 @@ public function testExecute(): void
186186
self::assertTrue($this->model->execute($this->ruleMock, 2, true));
187187
}
188188

189+
public function testExecuteWithCustomBatchSize()
190+
{
191+
$websiteId = 3;
192+
$productIds = [
193+
4 => [$websiteId => 1],
194+
5 => [$websiteId => 1],
195+
6 => [$websiteId => 1]
196+
];
197+
198+
$this->prepareResourceMock();
199+
$this->prepareRuleMock([3], $productIds, [10]);
200+
201+
$this->localeDateMock->method('getConfigTimezone')
202+
->willReturnMap([
203+
[ScopeInterface::SCOPE_WEBSITE, self::ADMIN_WEBSITE_ID, $this->adminTimeZone],
204+
[ScopeInterface::SCOPE_WEBSITE, $websiteId, $this->websiteTz]
205+
]);
206+
207+
$this->connectionMock->expects($this->exactly(2))->method('insertMultiple');
208+
self::assertTrue($this->model->execute($this->ruleMock, '2', true));
209+
}
210+
189211
/**
190212
* @param array $websitesIds
191213
* @param array $productIds

0 commit comments

Comments
 (0)