Skip to content

Instantly share code, notes, and snippets.

@lewisvoncken
Created February 14, 2018 12:42
Show Gist options
  • Save lewisvoncken/5609f6a83708353c29e2c9bc10125da1 to your computer and use it in GitHub Desktop.
Save lewisvoncken/5609f6a83708353c29e2c9bc10125da1 to your computer and use it in GitHub Desktop.
url_path_flat_children_category
From 96be1ce725616f6282636db8630f08f6d068c1e0 Mon Sep 17 00:00:00 2001
From: Lewis Voncken <lewis@experius.nl>
Date: Wed, 16 Aug 2017 16:07:17 +0000
Subject: [PATCH] [BUGFIX] Flat Category reindexList of AllChildren if the
url_key of the current category has changed
---
vendor/magento/module-catalog/Model/Category.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/vendor/magento/module-catalog/Model/Category.php b/vendor/magento/module-catalog/Model/Category.php
index d24169bc14ba..bc5fdec22e9e 100644
--- a/vendor/magento/module-catalog/Model/Category.php
+++ b/vendor/magento/module-catalog/Model/Category.php
@@ -1093,6 +1093,9 @@ public function reindex()
$flatIndexer = $this->indexerRegistry->get(Indexer\Category\Flat\State::INDEXER_ID);
if (!$flatIndexer->isScheduled()) {
$flatIndexer->reindexRow($this->getId());
+ if ($this->dataHasChangedFor('url_key')) {
+ $flatIndexer->reindexList(explode(',', $this->getAllChildren()));
+ }
}
}
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment