diff --git a/Block/Menu.php b/Block/Menu.php index a2c71339..07a0853e 100644 --- a/Block/Menu.php +++ b/Block/Menu.php @@ -191,9 +191,6 @@ private function getNodeCacheKeyInfo() $request = $this->getRequest(); switch ($request->getRouteName()) { - case 'cms': - $nodeType = 'cms_page'; - break; case 'catalog': $nodeType = 'category'; break; diff --git a/Block/NodeType/Category.php b/Block/NodeType/Category.php index bea264b6..990c5aab 100644 --- a/Block/NodeType/Category.php +++ b/Block/NodeType/Category.php @@ -78,19 +78,12 @@ public function getCurrentCategory() */ public function getNodeCacheKeyInfo() { - $info = [ + return [ 'module_' . $this->getRequest()->getModuleName(), 'controller_' . $this->getRequest()->getControllerName(), 'route_' . $this->getRequest()->getRouteName(), 'action_' . $this->getRequest()->getActionName() ]; - - $category = $this->getCurrentCategory(); - if ($category) { - $info[] = 'category_' . $category->getId(); - } - - return $info; } /** diff --git a/Block/NodeType/CategoryChild.php b/Block/NodeType/CategoryChild.php index dd6cf331..6768d611 100644 --- a/Block/NodeType/CategoryChild.php +++ b/Block/NodeType/CategoryChild.php @@ -50,18 +50,12 @@ public function __construct( */ public function getNodeCacheKeyInfo() { - $info = [ + return [ 'module_' . $this->getRequest()->getModuleName(), 'controller_' . $this->getRequest()->getControllerName(), 'route_' . $this->getRequest()->getRouteName(), 'action_' . $this->getRequest()->getActionName() ]; - $category = $this->getCurrentCategory(); - if ($category) { - $info[] = 'category-child_' . $category->getId(); - } - - return $info; } /** diff --git a/Block/NodeType/CmsPage.php b/Block/NodeType/CmsPage.php index d491dfe3..4241e9a6 100644 --- a/Block/NodeType/CmsPage.php +++ b/Block/NodeType/CmsPage.php @@ -74,21 +74,6 @@ public function __construct( $this->storesList = $storeManager->getStores(); } - /** - * @return array - */ - public function getNodeCacheKeyInfo() - { - $info = []; - $pageId = $this->getRequest()->getParam('page_id'); - - if ($pageId) { - $info[] = 'cms_page_' . $pageId; - } - - return $info; - } - /** * @inheritDoc */ diff --git a/CHANGELOG.md b/CHANGELOG.md index f7d5e8a6..ba67cc4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Update GH actions to github-actions-m2 and small code fixes to standards (#100322) - Don't show tag when there's no url (DEV-100390) +- Fixed issue about menu block being cached excessively ([#276](https://github.com/SnowdogApps/magento2-menu/issues/276)) ## [2.22.0] - 2023-05-08 ### Fixed diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js new file mode 100644 index 00000000..d30b14b5 --- /dev/null +++ b/view/frontend/requirejs-config.js @@ -0,0 +1,8 @@ +/* eslint-disable no-unused-vars */ +var config = { + map: { + '*': { + 'menu': 'Snowdog_Menu/js/menu.babel' + } + } +}; diff --git a/view/frontend/templates/menu.phtml b/view/frontend/templates/menu.phtml index 0178f473..4be0f02a 100755 --- a/view/frontend/templates/menu.phtml +++ b/view/frontend/templates/menu.phtml @@ -11,7 +11,10 @@ -