Skip to content

Commit 68c7282

Browse files
mark indexer as invalid if there were children categories
1 parent 722cf47 commit 68c7282

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,9 +1159,10 @@ public function reindex()
11591159
*/
11601160
public function afterDeleteCommit()
11611161
{
1162-
if ($this->getIsActive()) {
1162+
if ($this->getIsActive() || $this->getDeletedChildrenIds()) {
11631163
$this->reindex();
11641164
}
1165+
11651166
return parent::afterDeleteCommit();
11661167
}
11671168

app/code/Magento/Catalog/Model/ResourceModel/Category.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,10 @@ protected function _beforeDelete(\Magento\Framework\DataObject $object)
232232
*/
233233
protected function _afterDelete(DataObject $object)
234234
{
235-
if ($object->getIsActive()) {
235+
if ($object->getIsActive() || $object->getDeletedChildrenIds()) {
236236
$this->indexerProcessor->markIndexerAsInvalid();
237237
}
238+
238239
return parent::_afterDelete($object);
239240
}
240241

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(Processor $fulltextIndexerProcessor)
4040
*/
4141
public function afterDelete(Resource $subjectCategory, Resource $resultCategory, DataObject $object) : Resource
4242
{
43-
if ($object->getIsActive()) {
43+
if ($object->getIsActive() || $object->getDeletedChildrenIds()) {
4444
$this->fulltextIndexerProcessor->markIndexerAsInvalid();
4545
}
4646

dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ public function testCategoryDelete()
196196
public function testDeleteInactiveCategory(): void
197197
{
198198
$this->indexer->reindexAll();
199-
$indexerShouldBeValid = $this->indexer->isInvalid();
199+
$isInvalidIndexer = $this->indexer->isInvalid();
200200

201201
$this->categoryRepository->deleteByIdentifier(4);
202202

203203
$state = $this->indexer->getState();
204204
$state->loadByIndexer($this->indexer->getId());
205205
$status = $state->getStatus();
206206

207-
$this->assertFalse($indexerShouldBeValid);
207+
$this->assertFalse($isInvalidIndexer);
208208
$this->assertEquals(StateInterface::STATUS_VALID, $status);
209209
}
210210

0 commit comments

Comments
 (0)