Skip to content

Commit 6b41e71

Browse files
shochdoerferPierreGauthier
authored andcommitted
Fix indexing issue when no product variant is found
1 parent 0c77007 commit 6b41e71

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Indexer/AbstractIndexer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public function reindex(array $documentIdsToReindex = []): void
6363
$bulk = [];
6464
/** @var array $document */
6565
foreach ($this->getDocumentsToIndex($channel, $locale, $documentIdsToReindex) as $document) {
66+
if (0 === \count($document)) {
67+
continue;
68+
}
69+
/* @phpstan-ignore-next-line */
6670
$bulk[$document['id']] = json_encode($document);
6771
if (\count($bulk) >= $batchSize) {
6872
$this->indexOperation->executeBulk($index, $bulk);

src/Indexer/ProductIndexer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ public function getDocumentsToIndex(
9090
private function formatProduct(ProductInterface $product, ChannelInterface $channel, LocaleInterface $locale): array
9191
{
9292
$variants = $product->getVariants();
93-
/** @var ProductVariantInterface $variant */
93+
/** @var ProductVariantInterface|false $variant */
9494
$variant = $variants->first();
95+
if (false === $variant) {
96+
return [];
97+
}
9598

9699
/** @var int|string $productId */
97100
$productId = $product->getId();

0 commit comments

Comments
 (0)