-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathFulltext.php
More file actions
executable file
·112 lines (98 loc) · 3.11 KB
/
Fulltext.php
File metadata and controls
executable file
·112 lines (98 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
namespace Comwrap\ElasticsuiteBlog\Model\Post\Indexer;
use Magento\Framework\Search\Request\DimensionFactory;
use Magento\Framework\Indexer\SaveHandler\IndexerInterface;
use Magento\Store\Model\StoreManagerInterface;
use Comwrap\ElasticsuiteBlog\Model\Post\Indexer\Fulltext\Action\Full;
use Magento\Framework\Indexer\ActionInterface;
use Magento\Framework\Mview\ActionInterface as MviewActionInterface;
#[\AllowDynamicProperties]
class Fulltext implements ActionInterface, MviewActionInterface
{
/**
* @var string
*/
const INDEXER_ID = 'elasticsuite_blog_fulltext';
/**
* @var IndexerInterface
*/
private $indexerHandler;
/**
* @var StoreManagerInterface
*/
private $storeManager;
/**
* @var DimensionFactory
*/
private $dimensionFactory;
/**
* @var Full
*/
private $fullAction;
/**
* @param Full $fullAction The full index action
* @param IndexerInterface $indexerHandler The index handler
* @param StoreManagerInterface $storeManager The Store Manager
* @param DimensionFactory $dimensionFactory The dimension factory
* @param array $data The data
*/
public function __construct(
Full $fullAction,
IndexerInterface $indexerHandler,
StoreManagerInterface $storeManager,
DimensionFactory $dimensionFactory
) {
$this->fullAction = $fullAction;
$this->indexerHandler = $indexerHandler;
$this->storeManager = $storeManager;
$this->dimensionFactory = $dimensionFactory;
}
/**
* Execute materialization on ids entities
*
* @param int[] $ids The ids
*
* @return void
*/
public function execute($ids)
{
$storeIds = array_keys($this->storeManager->getStores());
/** @var IndexerHandler $saveHandler */
$saveHandler = $this->indexerHandler;
foreach ($storeIds as $storeId) {
$dimension = $this->dimensionFactory->create(['name' => 'scope', 'value' => $storeId]);
$saveHandler->deleteIndex([$dimension], new \ArrayObject($ids));
$saveHandler->saveIndex([$dimension], $this->fullAction->rebuildStoreIndex($storeId, $ids));
}
}
/**
* Execute full indexation
*
* @return void
*/
public function executeFull()
{
$storeIds = array_keys($this->storeManager->getStores());
/** @var IndexerHandler $saveHandler */
$saveHandler = $this->indexerHandler;
foreach ($storeIds as $storeId) {
$dimension = $this->dimensionFactory->create(['name' => 'scope', 'value' => $storeId]);
$saveHandler->cleanIndex([$dimension]);
$saveHandler->saveIndex([$dimension], $this->fullAction->rebuildStoreIndex($storeId));
}
}
/**
* {@inheritDoc}
*/
public function executeList(array $categoryIds)
{
$this->execute($categoryIds);
}
/**
* {@inheritDoc}
*/
public function executeRow($categoryId)
{
$this->execute([$categoryId]);
}
}