Skip to content

Commit

Permalink
MAGE-878: include non visible product to index logic updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrahman3177 committed Jul 10, 2024
1 parent 5d4170d commit 5c87a66
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public function rebuildStoreProductIndex(int $storeId, array $productIds): void
$this->logger->start('Indexing');
try {
$this->logger->start('ok');
$onlyVisible = $this->configHelper->includeNonVisibleProductsInIndex();
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex($storeId);
$collection = $this->productHelper->getProductCollectionQuery($storeId, $productIds, $onlyVisible);
$size = $collection->getSize();
if (!empty($productIds)) {
Expand Down Expand Up @@ -421,7 +421,8 @@ public function rebuildProductIndex(int $storeId, ?array $productIds, int $page,
if ($this->isIndexingEnabled($storeId) === false) {
return;
}
$collection = $this->productHelper->getProductCollectionQuery($storeId, null, $useTmpIndex);
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex($storeId);
$collection = $this->productHelper->getProductCollectionQuery($storeId, null, $onlyVisible);
$this->rebuildStoreProductIndexPage($storeId, $collection, $page, $pageSize, null, $productIds, $useTmpIndex);
}

Expand Down Expand Up @@ -928,7 +929,8 @@ public function getIndexDataByStoreIds(): array
*/
protected function deleteInactiveIds($storeId, $objectIds, $indexName): void
{
$collection = $this->productHelper->getProductCollectionQuery($storeId, $objectIds);
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex($storeId);
$collection = $this->productHelper->getProductCollectionQuery($storeId, $objectIds, $onlyVisible);
$dbIds = $collection->getAllIds();
$collection = null;
$idsToDeleteFromAlgolia = array_diff($objectIds, $dbIds);
Expand Down
3 changes: 2 additions & 1 deletion Model/Indexer/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public function execute($productIds)
}

$useTmpIndex = $this->configHelper->isQueueActive($storeId);
$collection = $this->productHelper->getProductCollectionQuery($storeId, $productIds, $useTmpIndex);
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex();
$collection = $this->productHelper->getProductCollectionQuery($storeId, $productIds, $onlyVisible);
$size = $collection->getSize();

$pages = ceil($size / $productsPerPage);
Expand Down
3 changes: 2 additions & 1 deletion ViewModel/Recommend/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public function getAllCartItems()
$cartItems[] = $item->getProductId();
}
$storeId = $this->storeManager->getStore()->getId();
$cartProductCollection = $this->productHelper->getProductCollectionQuery($storeId, array_unique($cartItems));
$onlyVisible = !$this->configHelper->includeNonVisibleProductsInIndex();
$cartProductCollection = $this->productHelper->getProductCollectionQuery($storeId, array_unique($cartItems), $onlyVisible);
if ($cartProductCollection->getSize() > 0 ){
foreach ($cartProductCollection as $product) {
$visibleCartItem[] = $product->getId();
Expand Down

0 comments on commit 5c87a66

Please sign in to comment.