@@ -64,17 +64,32 @@ public function __construct(
64
64
*/
65
65
public function loadAllAttributes (AbstractEntity $ resource , DataObject $ object = null )
66
66
{
67
+ $ suffix = $ this ->getLoadAllAttributesCacheSuffix ($ object );
68
+
67
69
$ typeCode = $ resource ->getEntityType ()->getEntityTypeCode ();
68
- $ attributes = $ this ->cache ->getAttributes ($ typeCode );
70
+ $ attributes = $ this ->cache ->getAttributes ($ typeCode, $ suffix );
69
71
if ($ attributes ) {
70
72
foreach ($ attributes as $ attribute ) {
71
73
$ resource ->addAttribute ($ attribute );
72
74
}
73
75
return $ resource ;
74
76
}
77
+ $ attributes = $ this ->checkAndInitAttributes ($ resource , $ object );
75
78
79
+ $ this ->cache ->saveAttributes ($ typeCode , $ attributes , $ suffix );
80
+ return $ resource ;
81
+ }
82
+
83
+ /**
84
+ * @param AbstractEntity $resource
85
+ * @param DataObject|null $object
86
+ * @return array
87
+ */
88
+ private function checkAndInitAttributes (AbstractEntity $ resource , DataObject $ object = null )
89
+ {
76
90
$ attributeCodes = $ this ->config ->getEntityAttributeCodes ($ resource ->getEntityType (), $ object );
77
91
$ attributes = [];
92
+
78
93
/**
79
94
* Check and init default attributes
80
95
*/
@@ -95,8 +110,23 @@ public function loadAllAttributes(AbstractEntity $resource, DataObject $object =
95
110
$ attribute = $ resource ->getAttribute ($ code );
96
111
$ attributes [] = $ attribute ;
97
112
}
98
- $ this ->cache ->saveAttributes ($ typeCode , $ attributes );
99
- return $ resource ;
113
+ return $ attributes ;
114
+ }
115
+
116
+ /**
117
+ * @param DataObject|null $object
118
+ * @return string
119
+ */
120
+ private function getLoadAllAttributesCacheSuffix (DataObject $ object = null )
121
+ {
122
+ $ attributeSetId = 0 ;
123
+ $ storeId = 0 ;
124
+ if (null !== $ object ) {
125
+ $ attributeSetId = $ object ->getAttributeSetId () ?: $ attributeSetId ;
126
+ $ storeId = $ object ->getStoreId () ?: $ storeId ;
127
+ }
128
+ $ suffix = $ storeId . '- ' . $ attributeSetId ;
129
+ return $ suffix ;
100
130
}
101
131
102
132
/**
0 commit comments