Skip to content

Commit 244bedc

Browse files
committed
MAGE-1122 Add logging
1 parent d8e9a01 commit 244bedc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Service/Product/MissingPriceIndexHandler.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Algolia\AlgoliaSearch\Service\Product;
44

5+
use Algolia\AlgoliaSearch\Helper\Logger;
56
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
67
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
78
use Magento\Framework\App\ResourceConnection;
@@ -21,6 +22,7 @@ class MissingPriceIndexHandler
2122
public function __construct(
2223
protected CollectionFactory $productCollectionFactory,
2324
protected ResourceConnection $resourceConnection,
25+
protected Logger $logger,
2426
IndexerRegistry $indexerRegistry
2527
)
2628
{
@@ -39,14 +41,18 @@ public function refreshPriceIndex(array|ProductCollection $products): array
3941
return [];
4042
}
4143

44+
$this->logger->log(__("Pricing records missing for %1 product(s)", count($reindexIds)));
45+
$this->logger->log(__("Reindexing product ID(s): %1", implode(', ', $reindexIds)));
46+
4247
$this->indexer->reindexList($reindexIds);
4348

4449
return $reindexIds;
4550
}
4651

4752
/**
48-
* @param string[]|ProductCollection $products
49-
* @return string[]
53+
* Analyzes a product collection and determines which (if any) records should have their prices reindexed
54+
* @param string[]|ProductCollection $products - either an explicit list of product ids or a product collection
55+
* @return string[] IDs of products that require price reindexing (will be empty if no indexing is required)
5056
* @throws \Zend_Db_Select_Exception
5157
*/
5258
protected function getProductIdsToReindex(array|ProductCollection $products): array
@@ -61,7 +67,7 @@ protected function getProductIdsToReindex(array|ProductCollection $products): ar
6167

6268
$state = $this->indexer->getState()->getStatus();
6369
if ($state === StateInterface::STATUS_INVALID) {
64-
return $productIds;
70+
return $productIds; //all records must be reindexed
6571
}
6672

6773
return $this->filterProductIds($productIds);

0 commit comments

Comments
 (0)