10
10
use Algolia \AlgoliaSearch \Model \Queue ;
11
11
use Algolia \AlgoliaSearch \Service \AlgoliaCredentialsManager ;
12
12
use Algolia \AlgoliaSearch \Service \Category \IndexBuilder as CategoryIndexBuilder ;
13
- use Algolia \ AlgoliaSearch \ Service \ Product \ IndexBuilder as ProductIndexBuilder ;
13
+ use Magento \ Framework \ Exception \ LocalizedException ;
14
14
use Magento \Framework \Exception \NoSuchEntityException ;
15
15
16
16
class BatchQueueProcessor implements BatchQueueProcessorInterface
17
17
{
18
- public static $ affectedProductIds = [];
19
-
20
18
public function __construct (
21
19
protected Data $ dataHelper ,
22
20
protected ConfigHelper $ configHelper ,
@@ -29,7 +27,7 @@ public function __construct(
29
27
* @param int $storeId
30
28
* @param array|null $entityIds
31
29
* @return void
32
- * @throws NoSuchEntityException
30
+ * @throws NoSuchEntityException|LocalizedException
33
31
*/
34
32
public function processBatch (int $ storeId , ?array $ entityIds = null ): void
35
33
{
@@ -43,8 +41,6 @@ public function processBatch(int $storeId, ?array $entityIds = null): void
43
41
return ;
44
42
}
45
43
46
- $ this ->rebuildAffectedProducts ($ storeId );
47
-
48
44
$ categoriesPerPage = $ this ->configHelper ->getNumberOfElementByPage ();
49
45
50
46
if (is_array ($ entityIds ) && count ($ entityIds ) > 0 ) {
@@ -56,37 +52,12 @@ public function processBatch(int $storeId, ?array $entityIds = null): void
56
52
$ this ->processFullReindex ($ storeId , $ categoriesPerPage );
57
53
}
58
54
59
- /**
60
- * @param int $storeId
61
- */
62
- protected function rebuildAffectedProducts ($ storeId )
63
- {
64
- $ affectedProducts = self ::$ affectedProductIds ;
65
- $ affectedProductsCount = count ($ affectedProducts );
66
-
67
- if ($ affectedProductsCount > 0 && $ this ->configHelper ->indexProductOnCategoryProductsUpdate ($ storeId )) {
68
- $ productsPerPage = $ this ->configHelper ->getNumberOfElementByPage ();
69
- foreach (array_chunk ($ affectedProducts , $ productsPerPage ) as $ chunk ) {
70
- /** @uses ProductIndexBuilder::buildIndexList() */
71
- $ this ->queue ->addToQueue (
72
- ProductIndexBuilder::class,
73
- 'buildIndexList ' ,
74
- [
75
- 'storeId ' => $ storeId ,
76
- 'entityIds ' => $ chunk ,
77
- ],
78
- count ($ chunk )
79
- );
80
- }
81
- }
82
- }
83
-
84
55
/**
85
56
* @param array $categoryIds
86
57
* @param int $categoriesPerPage
87
58
* @param int $storeId
88
59
*/
89
- protected function processSpecificCategories ($ categoryIds , $ categoriesPerPage , $ storeId )
60
+ protected function processSpecificCategories (array $ categoryIds , int $ categoriesPerPage , int $ storeId ): void
90
61
{
91
62
foreach (array_chunk ($ categoryIds , $ categoriesPerPage ) as $ chunk ) {
92
63
/** @uses CategoryIndexBuilder::buildIndexList */
@@ -106,10 +77,10 @@ protected function processSpecificCategories($categoryIds, $categoriesPerPage, $
106
77
* @param int $storeId
107
78
* @param int $categoriesPerPage
108
79
*
109
- * @throws Magento\Framework\Exception\LocalizedException
110
- * @throws Magento\Framework\Exception\NoSuchEntityException
80
+ * @throws NoSuchEntityException
81
+ * @throws LocalizedException
111
82
*/
112
- protected function processFullReindex ($ storeId , $ categoriesPerPage )
83
+ protected function processFullReindex (int $ storeId , int $ categoriesPerPage ): void
113
84
{
114
85
/** @uses IndicesConfigurator::saveConfigurationToAlgolia() */
115
86
$ this ->queue ->addToQueue (IndicesConfigurator::class, 'saveConfigurationToAlgolia ' , ['storeId ' => $ storeId ]);
0 commit comments