Skip to content

Instantly share code, notes, and snippets.

@tdgroot
Last active January 6, 2020 11:32
Show Gist options
  • Save tdgroot/f4c600ae1be9f5ab5b7f41a7058360e4 to your computer and use it in GitHub Desktop.
Save tdgroot/f4c600ae1be9f5ab5b7f41a7058360e4 to your computer and use it in GitHub Desktop.
--- a/Plugin/Block/Topmenu.php
+++ b/Plugin/Block/Topmenu.php
@@ -193,4 +193,21 @@ protected function getCategoryTree($storeId, $rootId)
return $collection;
}
+
+ /**
+ * Add active
+ *
+ * @param \Magento\Theme\Block\Html\Topmenu $subject
+ * @param string[] $result
+ * @return string[]
+ */
+ public function afterGetCacheKeyInfo(\Magento\Theme\Block\Html\Topmenu $subject, array $result)
+ {
+ $activeCategory = $this->getCurrentCategory();
+ if ($activeCategory) {
+ $result[] = Category::CACHE_TAG . '_' . $activeCategory->getId();
+ }
+
+ return $result;
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment