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
2929 */
3030 private $ eavConfig ;
3131
32+ /**
33+ * @var array
34+ */
35+ private $ metadataCache ;
36+
3237 /**
3338 * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
3439 * @param \Magento\Framework\Api\FilterBuilder $filterBuilder
@@ -75,18 +80,21 @@ public function get($attributeCode)
7580 */
7681 public function getCustomAttributesMetadata ($ dataObjectClassName = null )
7782 {
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 ];
9199 }
92100}
You can’t perform that action at this time.
0 commit comments