Skip to content

Commit 878c2b2

Browse files
authored
fix: custom entity layered navigation indexing in scheduled mode
Removed conditional checks for scheduled mode that prevented indexing operations from being executed. This ensures that: - Full reindexing works in both manual and scheduled modes - Partial reindexing works properly for entity updates - New filterable attributes now appear in layered navigation The indexer now consistently performs indexing operations regardless of the mode, allowing MVIEW to handle scheduling in scheduled mode.
1 parent d82ba02 commit 878c2b2

File tree

1 file changed

+13
-48
lines changed

1 file changed

+13
-48
lines changed

Model/Indexer/CustomEntity/Layered.php

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,12 @@ class Layered implements IndexerActionInterface, MviewActionInterface
6565
*/
6666
private $indexMutex;
6767

68-
/**
69-
* @var LoggerInterface
70-
*/
71-
private $logger;
72-
7368
/**
7469
* @param Layered\Action\FullFactory $fullActionFactory
7570
* @param Layered\Action\RowsFactory $rowsActionFactory
7671
* @param IndexerRegistry $indexerRegistry
7772
* @param CacheContext $cacheContext
7873
* @param IndexMutexInterface $indexMutex
79-
* @param LoggerInterface $logger
8074
* @param string $indexerId
8175
*/
8276
public function __construct(
@@ -85,15 +79,13 @@ public function __construct(
8579
IndexerRegistry $indexerRegistry,
8680
CacheContext $cacheContext,
8781
IndexMutexInterface $indexMutex,
88-
LoggerInterface $logger,
8982
string $indexerId = self::INDEXER_ID
9083
) {
9184
$this->fullActionFactory = $fullActionFactory;
9285
$this->rowsActionFactory = $rowsActionFactory;
9386
$this->indexerRegistry = $indexerRegistry;
9487
$this->cacheContext = $cacheContext;
9588
$this->indexMutex = $indexMutex;
96-
$this->logger = $logger;
9789
$this->indexerId = $indexerId;
9890
}
9991

@@ -105,13 +97,8 @@ public function __construct(
10597
*/
10698
public function execute($ids)
10799
{
108-
try {
109-
$this->executeAction($ids);
110-
$this->registerEntities($ids);
111-
} catch (\Exception $e) {
112-
$this->logger->error('Error during indexing specific entities: ' . $e->getMessage(), ['exception' => $e]);
113-
throw new LocalizedException(__('Could not rebuild index for specified entities: %1', $e->getMessage()), $e);
114-
}
100+
$this->executeAction($ids);
101+
$this->registerEntities($ids);
115102
}
116103

117104
/**
@@ -122,24 +109,14 @@ public function execute($ids)
122109
public function executeFull()
123110
{
124111
$indexer = $this->indexerRegistry->get($this->indexerId);
125-
126-
if ($indexer->isScheduled()) {
127-
// Skip manual reindex if indexer is in scheduled mode
128-
return;
129-
}
130-
131-
try {
132-
$this->indexMutex->execute(
133-
$this->indexerId,
134-
function () {
135-
$this->fullActionFactory->create()->execute();
136-
$this->registerTags();
137-
}
138-
);
139-
} catch (\Exception $e) {
140-
$this->logger->error('Error during full reindex: ' . $e->getMessage(), ['exception' => $e]);
141-
throw new LocalizedException(__('Could not rebuild index for all entities: %1', $e->getMessage()), $e);
142-
}
112+
113+
$this->indexMutex->execute(
114+
$this->indexerId,
115+
function () {
116+
$this->fullActionFactory->create()->execute();
117+
$this->registerTags();
118+
}
119+
);
143120
}
144121

145122
/**
@@ -150,15 +127,7 @@ function () {
150127
*/
151128
public function executeList(array $ids)
152129
{
153-
try {
154-
$this->executeAction($ids);
155-
} catch (\Exception $e) {
156-
$this->logger->error('Error during executing mview by ID list: ' . $e->getMessage(), [
157-
'exception' => $e,
158-
'ids' => implode(', ', $ids)
159-
]);
160-
throw new LocalizedException(__('Could not rebuild index for the specified entities: %1', $e->getMessage()), $e);
161-
}
130+
$this->executeAction($ids);
162131
}
163132

164133
/**
@@ -186,11 +155,7 @@ private function executeAction(array $ids)
186155

187156
$ids = array_unique($ids);
188157
$indexer = $this->indexerRegistry->get($this->indexerId);
189-
190-
if (!$indexer->isScheduled()) {
191-
$this->rowsActionFactory->create()->execute($ids);
192-
}
193-
158+
$this->rowsActionFactory->create()->execute($ids);
194159
return $this;
195160
}
196161

@@ -214,4 +179,4 @@ private function registerTags()
214179
{
215180
$this->cacheContext->registerTags([CustomEntity::CACHE_TAG]);
216181
}
217-
}
182+
}

0 commit comments

Comments
 (0)