|
9 | 9 | use Algolia\AlgoliaSearch\Exception\UnknownSkuException;
|
10 | 10 | use Algolia\AlgoliaSearch\Helper\Data as DataHelper;
|
11 | 11 | use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper;
|
| 12 | +use Algolia\AlgoliaSearch\Service\Product\IndexBuilder as ProductIndexBuilder; |
12 | 13 | use Magento\Backend\App\Action\Context;
|
13 | 14 | use Magento\Catalog\Api\ProductRepositoryInterface;
|
14 | 15 | use Magento\Framework\Controller\ResultFactory;
|
| 16 | +use Magento\Framework\Exception\LocalizedException; |
15 | 17 | use Magento\Framework\Exception\NoSuchEntityException;
|
16 | 18 | use Magento\Store\Model\StoreManagerInterface;
|
17 | 19 |
|
18 | 20 | class Save extends \Magento\Backend\App\Action
|
19 | 21 | {
|
20 | 22 | public const MAX_SKUS = 10;
|
21 | 23 |
|
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 |
| - */ |
41 | 24 | public function __construct(
|
42 |
| - Context $context, |
43 |
| - ProductRepositoryInterface $productRepository, |
44 |
| - StoreManagerInterface $storeManager, |
45 |
| - DataHelper $dataHelper, |
46 |
| - ProductHelper $productHelper |
| 25 | + protected Context $context, |
| 26 | + protected ProductRepositoryInterface $productRepository, |
| 27 | + protected StoreManagerInterface $storeManager, |
| 28 | + protected DataHelper $dataHelper, |
| 29 | + protected ProductHelper $productHelper, |
| 30 | + protected ProductIndexBuilder $productIndexBuilder |
47 | 31 | ) {
|
48 | 32 | parent::__construct($context);
|
49 |
| - $this->storeManager = $storeManager; |
50 |
| - $this->dataHelper = $dataHelper; |
51 |
| - $this->productHelper = $productHelper; |
52 |
| - $this->productRepository = $productRepository; |
53 | 33 | }
|
54 | 34 |
|
55 | 35 | /**
|
@@ -131,6 +111,7 @@ public function execute()
|
131 | 111 | * @param $stores
|
132 | 112 | * @return void
|
133 | 113 | * @throws NoSuchEntityException
|
| 114 | + * @throws LocalizedException |
134 | 115 | */
|
135 | 116 | protected function checkAndReindex($product, $stores)
|
136 | 117 | {
|
@@ -220,7 +201,7 @@ protected function checkAndReindex($product, $stores)
|
220 | 201 | $productIds = [$product->getId()];
|
221 | 202 | $productIds = array_merge($productIds, $this->productHelper->getParentProductIds($productIds));
|
222 | 203 |
|
223 |
| - $this->dataHelper->rebuildStoreProductIndex($storeId, $productIds); |
| 204 | + $this->productIndexBuilder->buildIndexList($storeId, $productIds); |
224 | 205 | $this->messageManager->addSuccessMessage(
|
225 | 206 | __(
|
226 | 207 | 'The Product "%1" (%2) has been reindexed for store "%3 / %4 / %5".',
|
|
0 commit comments