@@ -473,17 +473,19 @@ protected function _initAttributes($entityType)
473
473
return $ this ;
474
474
}
475
475
476
- if ($ this ->initAttributesFromCache ($ entityType )) {
476
+ $ entityTypeCode = $ entityType ->getEntityTypeCode ();
477
+ $ attributes = $ this ->_universalFactory ->create ($ entityType ->getEntityAttributeCollection ());
478
+ $ websiteId = $ attributes instanceof Collection ? $ this ->getWebsiteId ($ attributes ) : 0 ;
479
+ $ cacheKey = self ::ATTRIBUTES_CACHE_ID . '- ' . $ entityTypeCode . '- ' . $ websiteId ;
480
+
481
+ if ($ this ->isCacheEnabled () && $ this ->initAttributesFromCache ($ entityType , $ cacheKey )) {
477
482
return $ this ;
478
483
}
479
484
480
485
\Magento \Framework \Profiler::start ('EAV: ' . __METHOD__ , ['group ' => 'EAV ' , 'method ' => __METHOD__ ]);
481
486
482
- $ attributes = $ this ->_universalFactory ->create (
483
- $ entityType ->getEntityAttributeCollection ()
484
- )->setEntityTypeFilter (
485
- $ entityType
486
- )->getData ();
487
+ $ attributes = $ attributes ->setEntityTypeFilter ($ entityType )
488
+ ->getData ();
487
489
488
490
$ this ->_attributeData [$ entityTypeCode ] = [];
489
491
foreach ($ attributes as $ attribute ) {
@@ -497,7 +499,7 @@ protected function _initAttributes($entityType)
497
499
if ($ this ->isCacheEnabled ()) {
498
500
$ this ->_cache ->save (
499
501
$ this ->serializer ->serialize ($ this ->_attributeData [$ entityTypeCode ]),
500
- self :: ATTRIBUTES_CACHE_ID . $ entityTypeCode ,
502
+ $ cacheKey ,
501
503
[
502
504
\Magento \Eav \Model \Cache \Type::CACHE_TAG ,
503
505
\Magento \Eav \Model \Entity \Attribute::CACHE_TAG
@@ -949,15 +951,14 @@ private function setAttributeData($attribute, $entityType): AbstractAttribute
949
951
* Initialize attributes from cache for given entity type
950
952
*
951
953
* @param Type $entityType
954
+ * @param string $cacheKey
952
955
* @return bool
953
956
*/
954
- private function initAttributesFromCache (Type $ entityType )
957
+ private function initAttributesFromCache (Type $ entityType, string $ cacheKey )
955
958
{
956
959
$ entityTypeCode = $ entityType ->getEntityTypeCode ();
957
- $ attributeCollection = $ this ->_universalFactory ->create ($ entityType ->getEntityAttributeCollection ());
958
- $ websiteId = $ attributeCollection instanceof Collection ? $ this ->getWebsiteId ($ attributeCollection ) : 0 ;
959
- $ cacheKey = self ::ATTRIBUTES_CACHE_ID . '- ' . $ entityTypeCode . '- ' . $ websiteId ;
960
- if ($ this ->isCacheEnabled () && ($ attributes = $ this ->_cache ->load ($ cacheKey ))) {
960
+ $ attributes = $ this ->_cache ->load ($ cacheKey );
961
+ if ($ attributes ) {
961
962
$ attributes = $ this ->serializer ->unserialize ($ attributes );
962
963
if ($ attributes ) {
963
964
foreach ($ attributes as $ attribute ) {
0 commit comments