Skip to content

Commit 3fd459d

Browse files
committed
MAGETWO-52836: Enable EAV attributes caching
1 parent 956d83c commit 3fd459d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

app/code/Magento/Eav/Model/Entity/Attribute.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im
3737
*/
3838
protected $_eventPrefix = 'eav_entity_attribute';
3939

40+
/**
41+
* @var AttributeCache
42+
*/
43+
private $attributeCache;
44+
4045
/**
4146
* Parameter name in event
4247
*
@@ -299,9 +304,32 @@ public function beforeSave()
299304
public function afterSave()
300305
{
301306
$this->_getResource()->saveInSetIncluding($this);
307+
$this->getAttributeCache()->clear();
302308
return parent::afterSave();
303309
}
304310

311+
/**
312+
* @return $this
313+
*/
314+
public function afterDelete()
315+
{
316+
$this->getAttributeCache()->clear();
317+
return parent::afterDelete();
318+
}
319+
320+
/**
321+
* Attribute cache
322+
*
323+
* @return AttributeCache
324+
*/
325+
private function getAttributeCache()
326+
{
327+
if (!$this->attributeCache) {
328+
$this->attributeCache = ObjectManager::getInstance()->get(AttributeCache::class);
329+
}
330+
return $this->attributeCache;
331+
}
332+
305333
/**
306334
* Detect backend storage type using frontend input type
307335
*

0 commit comments

Comments
 (0)