File tree Expand file tree Collapse file tree 1 file changed +21
-13
lines changed
app/code/Magento/Catalog/Model/Category Expand file tree Collapse file tree 1 file changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ class AttributeRepository implements CategoryAttributeRepositoryInterface
29
29
*/
30
30
private $ eavConfig ;
31
31
32
+ /**
33
+ * @var array
34
+ */
35
+ private $ metadataCache ;
36
+
32
37
/**
33
38
* @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
34
39
* @param \Magento\Framework\Api\FilterBuilder $filterBuilder
@@ -75,18 +80,21 @@ public function get($attributeCode)
75
80
*/
76
81
public function getCustomAttributesMetadata ($ dataObjectClassName = null )
77
82
{
78
- $ defaultAttributeSetId = $ this ->eavConfig
79
- ->getEntityType (\Magento \Catalog \Api \Data \CategoryAttributeInterface::ENTITY_TYPE_CODE )
80
- ->getDefaultAttributeSetId ();
81
- $ searchCriteria = $ this ->searchCriteriaBuilder ->addFilters (
82
- [
83
- $ this ->filterBuilder
84
- ->setField ('attribute_set_id ' )
85
- ->setValue ($ defaultAttributeSetId )
86
- ->create (),
87
- ]
88
- );
89
-
90
- return $ this ->getList ($ searchCriteria ->create ())->getItems ();
83
+ if (empty ($ this ->metadataCache [$ dataObjectClassName ])) {
84
+ $ defaultAttributeSetId = $ this ->eavConfig
85
+ ->getEntityType (\Magento \Catalog \Api \Data \CategoryAttributeInterface::ENTITY_TYPE_CODE )
86
+ ->getDefaultAttributeSetId ();
87
+ $ searchCriteria = $ this ->searchCriteriaBuilder ->addFilters (
88
+ [
89
+ $ this ->filterBuilder
90
+ ->setField ('attribute_set_id ' )
91
+ ->setValue ($ defaultAttributeSetId )
92
+ ->create (),
93
+ ]
94
+ );
95
+ $ this ->metadataCache [$ dataObjectClassName ] = $ this ->getList ($ searchCriteria ->create ())
96
+ ->getItems ();
97
+ }
98
+ return $ this ->metadataCache [$ dataObjectClassName ];
91
99
}
92
100
}
You can’t perform that action at this time.
0 commit comments