Skip to content

Commit f581787

Browse files
committed
MAGETWO-52836: Enable EAV attributes caching
1 parent c7b7afc commit f581787

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

app/code/Magento/Customer/Model/Metadata/CachedMetadata.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CachedMetadata implements MetadataInterface
2020
/**
2121
* @var string
2222
*/
23-
protected $entityType = 'customer';
23+
protected $entityType = 'none';
2424

2525
/**
2626
* @var AttributeCache
@@ -79,7 +79,7 @@ public function getAllAttributesMetadata()
7979
if ($attributes !== false) {
8080
return $attributes;
8181
}
82-
$attributes = $this->metadata->getCustomAttributesMetadata();
82+
$attributes = $this->metadata->getAllAttributesMetadata();
8383
$this->getCache()->saveAttributes($this->entityType, $attributes, 'all');
8484
return $attributes;
8585
}

app/code/Magento/Customer/Model/Metadata/CustomerCachedMetadata.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
class CustomerCachedMetadata extends CachedMetadata implements CustomerMetadataInterface
1515
{
16+
protected $entityType = 'customer';
17+
1618
/**
1719
* Initialize dependencies.
1820
*

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Eav\Model\Entity\Attribute as EntityAttribute;
99
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
10+
use Magento\Eav\Model\Entity\AttributeCache;
1011
use Magento\Framework\DB\Select;
1112
use Magento\Framework\Model\AbstractModel;
1213
use Magento\Eav\Model\Config;
@@ -41,6 +42,11 @@ class Attribute extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
4142
*/
4243
private $config;
4344

45+
/**
46+
* @var AttributeCache
47+
*/
48+
private $attributeCache;
49+
4450
/**
4551
* Class constructor
4652
*
@@ -204,9 +210,21 @@ protected function _afterSave(AbstractModel $object)
204210
$object
205211
);
206212
$this->getConfig()->clear();
213+
$this->getAttributeCache()->clear();
207214
return parent::_afterSave($object);
208215
}
209216

217+
/**
218+
* @return AttributeCache
219+
* @deprecated
220+
*/
221+
private function getAttributeCache()
222+
{
223+
if (!$this->attributeCache) {
224+
$this->attributeCache = ObjectManager::getInstance()->get(Config::class);
225+
}
226+
return $this->attributeCache;
227+
}
210228
/**
211229
* @return Config
212230
* @deprecated

0 commit comments

Comments
 (0)