File tree Expand file tree Collapse file tree 1 file changed +21
-6
lines changed
app/code/Magento/Cms/Observer Expand file tree Collapse file tree 1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change 1818
1919namespace Magento \Cms \Observer ;
2020
21+ use Magento \Catalog \Model \Product ;
2122use Magento \Cms \Model \Page ;
2223use Magento \Framework \App \Cache \Type \Layout as LayoutCache ;
2324use Magento \Framework \App \Cache \StateInterface as CacheState ;
2425use Magento \Framework \App \Cache \Tag \Resolver ;
2526use Magento \Framework \Event \Observer ;
2627use Magento \Framework \Event \ObserverInterface ;
28+ use Magento \Widget \Model \Widget \Instance ;
2729
2830/**
2931 * Invalidates layout cache.
@@ -78,7 +80,7 @@ public function execute(Observer $observer)
7880 if (!$ this ->cacheState ->isEnabled (LayoutCache::TYPE_IDENTIFIER )) {
7981 return ;
8082 }
81-
83+
8284 if (!$ object ->dataHasChangedFor (Page::PAGE_LAYOUT )) {
8385 return ;
8486 }
@@ -96,10 +98,23 @@ public function execute(Observer $observer)
9698 */
9799 public function getAdditionalTags ($ object ): string
98100 {
99- return sprintf (
100- '%s_%s ' ,
101- 'CMS_PAGE_VIEW_ID ' ,
102- str_replace ('- ' , '_ ' , strtoupper ($ object ->getIdentifier ()))
103- );
101+ $ tag = '' ;
102+ if ($ object instanceof Page) {
103+ $ tag = sprintf (
104+ '%s_%s ' ,
105+ 'CMS_PAGE_VIEW_ID ' ,
106+ str_replace ('- ' , '_ ' , strtoupper ($ object ->getIdentifier ()))
107+ );
108+ } elseif ($ object instanceof Product) {
109+ $ tag = sprintf (
110+ '%s ' ,
111+ str_replace (
112+ '{{ID}} ' ,
113+ (string ) $ object ->getId (),
114+ Instance::SINGLE_PRODUCT_LAYOUT_HANDLE
115+ ),
116+ );
117+ }
118+ return $ tag ;
104119 }
105120}
You can’t perform that action at this time.
0 commit comments