Skip to content

Commit 5c87a66

Browse files
committed
MAGE-878: include non visible product to index logic updated.
1 parent 5d4170d commit 5c87a66

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Helper/Data.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public function rebuildStoreProductIndex(int $storeId, array $productIds): void
376376
$this->logger->start('Indexing');
377377
try {
378378
$this->logger->start('ok');
379-
$onlyVisible = $this->configHelper->includeNonVisibleProductsInIndex();
379+
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex($storeId);
380380
$collection = $this->productHelper->getProductCollectionQuery($storeId, $productIds, $onlyVisible);
381381
$size = $collection->getSize();
382382
if (!empty($productIds)) {
@@ -421,7 +421,8 @@ public function rebuildProductIndex(int $storeId, ?array $productIds, int $page,
421421
if ($this->isIndexingEnabled($storeId) === false) {
422422
return;
423423
}
424-
$collection = $this->productHelper->getProductCollectionQuery($storeId, null, $useTmpIndex);
424+
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex($storeId);
425+
$collection = $this->productHelper->getProductCollectionQuery($storeId, null, $onlyVisible);
425426
$this->rebuildStoreProductIndexPage($storeId, $collection, $page, $pageSize, null, $productIds, $useTmpIndex);
426427
}
427428

@@ -928,7 +929,8 @@ public function getIndexDataByStoreIds(): array
928929
*/
929930
protected function deleteInactiveIds($storeId, $objectIds, $indexName): void
930931
{
931-
$collection = $this->productHelper->getProductCollectionQuery($storeId, $objectIds);
932+
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex($storeId);
933+
$collection = $this->productHelper->getProductCollectionQuery($storeId, $objectIds, $onlyVisible);
932934
$dbIds = $collection->getAllIds();
933935
$collection = null;
934936
$idsToDeleteFromAlgolia = array_diff($objectIds, $dbIds);

Model/Indexer/Product.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ public function execute($productIds)
9595
}
9696

9797
$useTmpIndex = $this->configHelper->isQueueActive($storeId);
98-
$collection = $this->productHelper->getProductCollectionQuery($storeId, $productIds, $useTmpIndex);
98+
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex();
99+
$collection = $this->productHelper->getProductCollectionQuery($storeId, $productIds, $onlyVisible);
99100
$size = $collection->getSize();
100101

101102
$pages = ceil($size / $productsPerPage);

ViewModel/Recommend/Cart.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public function getAllCartItems()
6464
$cartItems[] = $item->getProductId();
6565
}
6666
$storeId = $this->storeManager->getStore()->getId();
67-
$cartProductCollection = $this->productHelper->getProductCollectionQuery($storeId, array_unique($cartItems));
67+
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex();
68+
$cartProductCollection = $this->productHelper->getProductCollectionQuery($storeId, array_unique($cartItems), $onlyVisible);
6869
if ($cartProductCollection->getSize() > 0 ){
6970
foreach ($cartProductCollection as $product) {
7071
$visibleCartItem[] = $product->getId();

0 commit comments

Comments
 (0)