2
2
3
3
namespace Algolia \AlgoliaSearch \Service \Product ;
4
4
5
+ use Algolia \AlgoliaSearch \Helper \Logger ;
5
6
use Magento \Catalog \Model \ResourceModel \Product \Collection as ProductCollection ;
6
7
use Magento \Catalog \Model \ResourceModel \Product \CollectionFactory ;
7
8
use Magento \Framework \App \ResourceConnection ;
@@ -21,6 +22,7 @@ class MissingPriceIndexHandler
21
22
public function __construct (
22
23
protected CollectionFactory $ productCollectionFactory ,
23
24
protected ResourceConnection $ resourceConnection ,
25
+ protected Logger $ logger ,
24
26
IndexerRegistry $ indexerRegistry
25
27
)
26
28
{
@@ -39,14 +41,18 @@ public function refreshPriceIndex(array|ProductCollection $products): array
39
41
return [];
40
42
}
41
43
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
+
42
47
$ this ->indexer ->reindexList ($ reindexIds );
43
48
44
49
return $ reindexIds ;
45
50
}
46
51
47
52
/**
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)
50
56
* @throws \Zend_Db_Select_Exception
51
57
*/
52
58
protected function getProductIdsToReindex (array |ProductCollection $ products ): array
@@ -61,7 +67,7 @@ protected function getProductIdsToReindex(array|ProductCollection $products): ar
61
67
62
68
$ state = $ this ->indexer ->getState ()->getStatus ();
63
69
if ($ state === StateInterface::STATUS_INVALID ) {
64
- return $ productIds ;
70
+ return $ productIds ; //all records must be reindexed
65
71
}
66
72
67
73
return $ this ->filterProductIds ($ productIds );
0 commit comments