Skip to content

Commit bee0050

Browse files
committed
MAGETWO-45666: "Refresh cache" message is not displayed when changing category page layout
- Added observer for invalidating cache on category design change
1 parent 9d0022d commit bee0050

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
128128
'page_layout',
129129
'custom_layout_update',
130130
'custom_apply_to_products',
131+
'custom_use_parent_settings',
131132
];
132133

133134
/**
@@ -317,9 +318,11 @@ protected function getCustomAttributesCodes()
317318
* @throws \Magento\Framework\Exception\LocalizedException
318319
* @return \Magento\Catalog\Model\ResourceModel\Category
319320
* @deprecated because resource models should be used directly
321+
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
320322
*/
321323
protected function _getResource()
322324
{
325+
//phpcs:enable Generic.CodeAnalysis.UselessOverridingMethod
323326
return parent::_getResource();
324327
}
325328

@@ -606,11 +609,13 @@ public function getUrl()
606609
return $this->getData('url');
607610
}
608611

609-
$rewrite = $this->urlFinder->findOneByData([
610-
UrlRewrite::ENTITY_ID => $this->getId(),
611-
UrlRewrite::ENTITY_TYPE => CategoryUrlRewriteGenerator::ENTITY_TYPE,
612-
UrlRewrite::STORE_ID => $this->getStoreId(),
613-
]);
612+
$rewrite = $this->urlFinder->findOneByData(
613+
[
614+
UrlRewrite::ENTITY_ID => $this->getId(),
615+
UrlRewrite::ENTITY_TYPE => CategoryUrlRewriteGenerator::ENTITY_TYPE,
616+
UrlRewrite::STORE_ID => $this->getStoreId(),
617+
]
618+
);
614619
if ($rewrite) {
615620
$this->setData('url', $this->getUrlInstance()->getDirectUrl($rewrite->getRequestPath()));
616621
Profiler::stop('REWRITE: ' . __METHOD__);

app/code/Magento/Catalog/Observer/InvalidateCacheOnCategoryDesignChange.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@
1515
*/
1616
class InvalidateCacheOnCategoryDesignChange implements ObserverInterface
1717
{
18-
/**
19-
* @var array
20-
*/
21-
private $designAttributes = [
22-
'custom_design',
23-
'page_layout',
24-
'custom_layout_update',
25-
'custom_apply_to_products',
26-
'custom_use_parent_settings'
27-
];
28-
2918
/**
3019
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
3120
*/
@@ -43,8 +32,8 @@ public function execute(Observer $observer)
4332
{
4433
$category = $observer->getEvent()->getEntity();
4534
if (!$category->isObjectNew()) {
46-
foreach ($this->designAttributes as $designAttribute) {
47-
if ($category->dataHasChangedFor($designAttribute)) {
35+
foreach ($category->getDesignAttributes() as $designAttribute) {
36+
if ($category->dataHasChangedFor($designAttribute->getAttributeCode())) {
4837
$this->cacheTypeList->invalidate(
4938
[
5039
\Magento\PageCache\Model\Cache\Type::TYPE_IDENTIFIER,

0 commit comments

Comments
 (0)