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 18
18
19
19
namespace Magento \Cms \Observer ;
20
20
21
+ use Magento \Catalog \Model \Product ;
21
22
use Magento \Cms \Model \Page ;
22
23
use Magento \Framework \App \Cache \Type \Layout as LayoutCache ;
23
24
use Magento \Framework \App \Cache \StateInterface as CacheState ;
24
25
use Magento \Framework \App \Cache \Tag \Resolver ;
25
26
use Magento \Framework \Event \Observer ;
26
27
use Magento \Framework \Event \ObserverInterface ;
28
+ use Magento \Widget \Model \Widget \Instance ;
27
29
28
30
/**
29
31
* Invalidates layout cache.
@@ -78,7 +80,7 @@ public function execute(Observer $observer)
78
80
if (!$ this ->cacheState ->isEnabled (LayoutCache::TYPE_IDENTIFIER )) {
79
81
return ;
80
82
}
81
-
83
+
82
84
if (!$ object ->dataHasChangedFor (Page::PAGE_LAYOUT )) {
83
85
return ;
84
86
}
@@ -96,10 +98,23 @@ public function execute(Observer $observer)
96
98
*/
97
99
public function getAdditionalTags ($ object ): string
98
100
{
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 ;
104
119
}
105
120
}
You can’t perform that action at this time.
0 commit comments