Skip to content

Commit ef00cca

Browse files
committed
MAGE-1095: remove occurences of deprecated methods within the codebase + improve Indexing Queue display
1 parent d27bd76 commit ef00cca

File tree

13 files changed

+128
-79
lines changed

13 files changed

+128
-79
lines changed

Controller/Adminhtml/Reindex/Save.php

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Algolia\AlgoliaSearch\Exception\UnknownSkuException;
1010
use Algolia\AlgoliaSearch\Helper\Data as DataHelper;
1111
use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper;
12+
use Algolia\AlgoliaSearch\Service\Product\IndexBuilder as ProductIndexBuilder;
1213
use Magento\Backend\App\Action\Context;
1314
use Magento\Catalog\Api\ProductRepositoryInterface;
1415
use Magento\Framework\Controller\ResultFactory;
@@ -19,37 +20,15 @@ class Save extends \Magento\Backend\App\Action
1920
{
2021
public const MAX_SKUS = 10;
2122

22-
/** @var ProductRepositoryInterface */
23-
protected $productRepository;
24-
25-
/** @var StoreManagerInterface */
26-
protected $storeManager;
27-
28-
/** @var DataHelper */
29-
protected $dataHelper;
30-
31-
/** @var ProductHelper */
32-
protected $productHelper;
33-
34-
/**
35-
* @param Context $context
36-
* @param ProductRepositoryInterface $productRepository
37-
* @param StoreManagerInterface $storeManager
38-
* @param DataHelper $dataHelper
39-
* @param ProductHelper $productHelper
40-
*/
4123
public function __construct(
42-
Context $context,
43-
ProductRepositoryInterface $productRepository,
44-
StoreManagerInterface $storeManager,
45-
DataHelper $dataHelper,
46-
ProductHelper $productHelper
24+
protected Context $context,
25+
protected ProductRepositoryInterface $productRepository,
26+
protected StoreManagerInterface $storeManager,
27+
protected DataHelper $dataHelper,
28+
protected ProductHelper $productHelper,
29+
protected ProductIndexBuilder $productIndexBuilder
4730
) {
4831
parent::__construct($context);
49-
$this->storeManager = $storeManager;
50-
$this->dataHelper = $dataHelper;
51-
$this->productHelper = $productHelper;
52-
$this->productRepository = $productRepository;
5332
}
5433

5534
/**
@@ -220,7 +199,7 @@ protected function checkAndReindex($product, $stores)
220199
$productIds = [$product->getId()];
221200
$productIds = array_merge($productIds, $this->productHelper->getParentProductIds($productIds));
222201

223-
$this->dataHelper->rebuildStoreProductIndex($storeId, $productIds);
202+
$this->productIndexBuilder->rebuildIndexIds($storeId, $productIds);
224203
$this->messageManager->addSuccessMessage(
225204
__(
226205
'The Product "%1" (%2) has been reindexed for store "%3 / %4 / %5".',

Helper/AdapterHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Algolia\AlgoliaSearch\Helper;
44

55
use Algolia\AlgoliaSearch\Helper\Adapter\FiltersHelper;
6-
use Algolia\AlgoliaSearch\Helper\Data as AlgoliaDataHelper;
76
use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager;
7+
use Algolia\AlgoliaSearch\Service\Product\BackendSearch;
88
use Magento\CatalogSearch\Helper\Data as CatalogSearchDataHelper;
99

1010
class AdapterHelper
@@ -14,7 +14,7 @@ class AdapterHelper
1414

1515
public function __construct(
1616
protected CatalogSearchDataHelper $catalogSearchHelper,
17-
protected AlgoliaDataHelper $algoliaHelper,
17+
protected BackendSearch $backendSearch,
1818
protected FiltersHelper $filtersHelper,
1919
protected ConfigHelper $configHelper,
2020
protected AlgoliaCredentialsManager $algoliaCredentialsManager
@@ -52,7 +52,7 @@ public function getDocumentsFromAlgolia()
5252
}
5353
}
5454

55-
return $this->algoliaHelper->getSearchResult($algoliaQuery, $storeId, $searchParams, $targetedIndex);
55+
return $this->backendSearch->getSearchResult($algoliaQuery, $storeId, $searchParams, $targetedIndex);
5656
}
5757

5858
/**

Model/Indexer/AdditionalSection.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
use Algolia\AlgoliaSearch\Helper\Data;
77
use Algolia\AlgoliaSearch\Model\Queue;
88
use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager;
9+
use Algolia\AlgoliaSearch\Service\AdditionalSection\IndexBuilder as AdditionalSectionIndexBuilder;
910
use Magento\Store\Model\StoreManagerInterface;
1011

1112
class AdditionalSection implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
1213
{
1314
public function __construct(
1415
protected StoreManagerInterface $storeManager,
15-
protected Data $fullAction,
16+
protected Data $dataHelper,
1617
protected Queue $queue,
1718
protected ConfigHelper $configHelper,
1819
protected AlgoliaCredentialsManager $algoliaCredentialsManager
@@ -29,7 +30,7 @@ public function executeFull()
2930
$storeIds = array_keys($this->storeManager->getStores());
3031

3132
foreach ($storeIds as $storeId) {
32-
if ($this->fullAction->isIndexingEnabled($storeId) === false) {
33+
if ($this->dataHelper->isIndexingEnabled($storeId) === false) {
3334
continue;
3435
}
3536

@@ -39,9 +40,10 @@ public function executeFull()
3940
return;
4041
}
4142

43+
/** @uses AdditionalSectionIndexBuilder::rebuildIndex() */
4244
$this->queue->addToQueue(
43-
Data::class,
44-
'rebuildStoreAdditionalSectionsIndex',
45+
AdditionalSectionIndexBuilder::class,
46+
'rebuildIndex',
4547
['storeId' => $storeId],
4648
1
4749
);

Model/Indexer/Category.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Algolia\AlgoliaSearch\Model\IndicesConfigurator;
99
use Algolia\AlgoliaSearch\Model\Queue;
1010
use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager;
11+
use Algolia\AlgoliaSearch\Service\Product\IndexBuilder as ProductIndexBuilder;
12+
use Algolia\AlgoliaSearch\Service\Category\IndexBuilder as CategoryIndexBuilder;
1113
use Magento\Store\Model\StoreManagerInterface;
1214

1315
class Category implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
@@ -17,7 +19,7 @@ class Category implements \Magento\Framework\Indexer\ActionInterface, \Magento\F
1719
public function __construct(
1820
protected StoreManagerInterface $storeManager,
1921
protected CategoryHelper $categoryHelper,
20-
protected Data $fullAction,
22+
protected Data $dataHelper,
2123
protected Queue $queue,
2224
protected ConfigHelper $configHelper,
2325
protected AlgoliaCredentialsManager $algoliaCredentialsManager
@@ -29,7 +31,7 @@ public function execute($categoryIds)
2931
$storeIds = array_keys($this->storeManager->getStores());
3032

3133
foreach ($storeIds as $storeId) {
32-
if ($this->fullAction->isIndexingEnabled($storeId) === false) {
34+
if ($this->dataHelper->isIndexingEnabled($storeId) === false) {
3335
continue;
3436
}
3537

@@ -79,10 +81,10 @@ private function rebuildAffectedProducts($storeId)
7981
if ($affectedProductsCount > 0 && $this->configHelper->indexProductOnCategoryProductsUpdate($storeId)) {
8082
$productsPerPage = $this->configHelper->getNumberOfElementByPage();
8183
foreach (array_chunk($affectedProducts, $productsPerPage) as $chunk) {
82-
/** @uses Data::rebuildStoreProductIndex() */
84+
/** @uses ProductIndexBuilder::rebuildIndexIds() */
8385
$this->queue->addToQueue(
84-
Data::class,
85-
'rebuildStoreProductIndex',
86+
ProductIndexBuilder::class,
87+
'rebuildIndexIds',
8688
[
8789
'storeId' => $storeId,
8890
'productIds' => $chunk,
@@ -101,10 +103,10 @@ private function rebuildAffectedProducts($storeId)
101103
private function processSpecificCategories($categoryIds, $categoriesPerPage, $storeId)
102104
{
103105
foreach (array_chunk($categoryIds, $categoriesPerPage) as $chunk) {
104-
/** @uses Data::rebuildStoreCategoryIndex */
106+
/** @uses CategoryIndexBuilder::rebuildIndexIds */
105107
$this->queue->addToQueue(
106-
Data::class,
107-
'rebuildStoreCategoryIndex',
108+
CategoryIndexBuilder::class,
109+
'rebuildIndexIds',
108110
[
109111
'storeId' => $storeId,
110112
'categoryIds' => $chunk,
@@ -138,8 +140,8 @@ private function processFullReindex($storeId, $categoriesPerPage)
138140
'pageSize' => $categoriesPerPage,
139141
];
140142

141-
/** @uses Data::rebuildCategoryIndex() */
142-
$this->queue->addToQueue(Data::class, 'rebuildCategoryIndex', $data, $categoriesPerPage, true);
143+
/** @uses CategoryIndexBuilder::rebuildIndex() */
144+
$this->queue->addToQueue(CategoryIndexBuilder::class, 'rebuildIndex', $data, $categoriesPerPage, true);
143145
}
144146
}
145147
}

Model/Indexer/DeleteProduct.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@
66
use Algolia\AlgoliaSearch\Helper\Data;
77
use Algolia\AlgoliaSearch\Model\Queue;
88
use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager;
9+
use Algolia\AlgoliaSearch\Service\Product\IndexBuilder as ProductIndexBuilder;
910
use Magento\Store\Model\StoreManagerInterface;
1011

1112
class DeleteProduct implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
1213
{
1314
public function __construct(
1415
protected StoreManagerInterface $storeManager,
15-
protected Data $fullAction,
16+
protected Data $dataHelper,
1617
protected AlgoliaHelper $algoliaHelper,
1718
protected Queue $queue,
18-
protected AlgoliaCredentialsManager $algoliaCredentialsManager
19+
protected AlgoliaCredentialsManager $algoliaCredentialsManager,
20+
protected ProductIndexBuilder $productIndexBuilder
1921
)
2022
{}
2123

@@ -29,7 +31,7 @@ public function executeFull()
2931
$storeIds = array_keys($this->storeManager->getStores());
3032

3133
foreach ($storeIds as $storeId) {
32-
if ($this->fullAction->isIndexingEnabled($storeId) === false) {
34+
if ($this->dataHelper->isIndexingEnabled($storeId) === false) {
3335
continue;
3436
}
3537

@@ -39,7 +41,7 @@ public function executeFull()
3941
return;
4042
}
4143

42-
$this->fullAction->deleteInactiveProducts($storeId);
44+
$this->productIndexBuilder->deleteInactiveProducts($storeId);
4345
}
4446
}
4547

Model/Indexer/Page.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
use Algolia\AlgoliaSearch\Helper\Entity\PageHelper;
99
use Algolia\AlgoliaSearch\Model\Queue;
1010
use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager;
11+
use Algolia\AlgoliaSearch\Service\Page\IndexBuilder as PageIndexBuilder;
1112
use Magento\Store\Model\StoreManagerInterface;
1213

1314
class Page implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
1415
{
1516
public function __construct(
1617
protected StoreManagerInterface $storeManager,
1718
protected PageHelper $pageHelper,
18-
protected Data $fullAction,
19+
protected Data $dataHelper,
1920
protected AlgoliaHelper $algoliaHelper,
2021
protected Queue $queue,
2122
protected ConfigHelper $configHelper,
@@ -32,7 +33,7 @@ public function execute($ids)
3233
$storeIds = $this->pageHelper->getStores();
3334

3435
foreach ($storeIds as $storeId) {
35-
if ($this->fullAction->isIndexingEnabled($storeId) === false) {
36+
if ($this->dataHelper->isIndexingEnabled($storeId) === false) {
3637
continue;
3738
}
3839

@@ -48,9 +49,10 @@ public function execute($ids)
4849
$data['pageIds'] = $ids;
4950
}
5051

52+
/** @uses PageIndexBuilder::rebuildIndex() */
5153
$this->queue->addToQueue(
52-
Data::class,
53-
'rebuildStorePageIndex',
54+
PageIndexBuilder::class,
55+
'rebuildIndex',
5456
$data,
5557
is_array($ids) ? count($ids) : 1
5658
);

Model/Indexer/Product.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Algolia\AlgoliaSearch\Model\IndicesConfigurator;
1212
use Algolia\AlgoliaSearch\Model\Queue;
1313
use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager;
14+
use Algolia\AlgoliaSearch\Service\Product\IndexBuilder as ProductIndexBuilder;
1415
use Magento\Framework\Exception\NoSuchEntityException;
1516
use Magento\Store\Model\StoreManagerInterface;
1617

@@ -20,7 +21,7 @@ class Product implements \Magento\Framework\Indexer\ActionInterface, \Magento\Fr
2021
public function __construct(
2122
protected StoreManagerInterface $storeManager,
2223
protected ProductHelper $productHelper,
23-
protected Data $baseHelper,
24+
protected Data $dataHelper,
2425
protected AlgoliaHelper $algoliaHelper,
2526
protected ConfigHelper $configHelper,
2627
protected Queue $queue,
@@ -38,7 +39,7 @@ public function execute($productIds)
3839
$areParentsLoaded = false;
3940

4041
foreach ($storeIds as $storeId) {
41-
if ($this->baseHelper->isIndexingEnabled($storeId) === false) {
42+
if ($this->dataHelper->isIndexingEnabled($storeId) === false) {
4243
continue;
4344
}
4445

@@ -57,10 +58,10 @@ public function execute($productIds)
5758

5859
if (is_array($productIds) && count($productIds) > 0) {
5960
foreach (array_chunk($productIds, $productsPerPage) as $chunk) {
60-
/** @uses Data::rebuildStoreProductIndex() */
61+
/** @uses ProductIndexBuilder::rebuildIndexIds() */
6162
$this->queue->addToQueue(
62-
Data::class,
63-
'rebuildStoreProductIndex',
63+
ProductIndexBuilder::class,
64+
'rebuildIndexIds',
6465
['storeId' => $storeId, 'productIds' => $chunk],
6566
count($chunk)
6667
);
@@ -94,8 +95,14 @@ public function execute($productIds)
9495
'useTmpIndex' => $useTmpIndex,
9596
];
9697

97-
/** @uses Data::rebuildProductIndex() */
98-
$this->queue->addToQueue(Data::class, 'rebuildProductIndex', $data, $productsPerPage, true);
98+
/** @uses ProductIndexBuilder::rebuildIndex() */
99+
$this->queue->addToQueue(
100+
ProductIndexBuilder::class,
101+
'rebuildIndex',
102+
$data,
103+
$productsPerPage,
104+
true
105+
);
99106
}
100107

101108
if ($useTmpIndex) {

Model/Indexer/Suggestion.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
use Algolia\AlgoliaSearch\Helper\Entity\SuggestionHelper;
99
use Algolia\AlgoliaSearch\Model\Queue;
1010
use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager;
11+
use Algolia\AlgoliaSearch\Service\Suggestion\IndexBuilder as SuggestionIndexBuilder;
1112
use Magento\Store\Model\StoreManagerInterface;
1213

1314
class Suggestion implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
1415
{
1516
public function __construct(
1617
protected StoreManagerInterface $storeManager,
1718
protected SuggestionHelper $suggestionHelper,
18-
protected Data $fullAction,
19+
protected Data $dataHelper,
1920
protected AlgoliaHelper $algoliaHelper,
2021
protected Queue $queue,
2122
protected ConfigHelper $configHelper,
@@ -32,7 +33,7 @@ public function executeFull()
3233
$storeIds = array_keys($this->storeManager->getStores());
3334

3435
foreach ($storeIds as $storeId) {
35-
if ($this->fullAction->isIndexingEnabled($storeId) === false) {
36+
if ($this->dataHelper->isIndexingEnabled($storeId) === false) {
3637
continue;
3738
}
3839

@@ -42,7 +43,13 @@ public function executeFull()
4243
return;
4344
}
4445

45-
$this->queue->addToQueue(Data::class, 'rebuildStoreSuggestionIndex', ['storeId' => $storeId], 1);
46+
/** @uses SuggestionIndexBuilder::rebuildIndex() */
47+
$this->queue->addToQueue(
48+
SuggestionIndexBuilder::class,
49+
'rebuildIndex',
50+
['storeId' => $storeId],
51+
1
52+
);
4653
}
4754
}
4855

0 commit comments

Comments
 (0)