Skip to content

Commit 25d2e42

Browse files
committed
ACP2E-3063: [Cloud] Cache is not getting invalidated.
- without test
1 parent 8f504f5 commit 25d2e42

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

app/code/Magento/Cms/Observer/InvalidateLayoutCacheObserver.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
namespace Magento\Cms\Observer;
2020

21+
use Magento\Catalog\Model\Product;
2122
use Magento\Cms\Model\Page;
2223
use Magento\Framework\App\Cache\Type\Layout as LayoutCache;
2324
use Magento\Framework\App\Cache\StateInterface as CacheState;
2425
use Magento\Framework\App\Cache\Tag\Resolver;
2526
use Magento\Framework\Event\Observer;
2627
use 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
}

0 commit comments

Comments
 (0)