Skip to content

Commit eaa08ee

Browse files
author
Viktor Kopin
committed
MC-37665: Updating a category through the REST API will uncheck "Use Default Value" on a bunch of attributes
1 parent 2e6b1b4 commit eaa08ee

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

app/code/Magento/Catalog/Model/CategoryRepository/PopulateWithValues.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class PopulateWithValues
4242
*/
4343
private $filterBuilder;
4444

45+
/**
46+
* @var AttributeInterface[]
47+
*/
48+
private $attributes;
49+
4550
/**
4651
* @param ScopeOverriddenValue $scopeOverriddenValue
4752
* @param AttributeRepository $attributeRepository
@@ -120,8 +125,12 @@ function () {
120125
*
121126
* @return AttributeInterface[]
122127
*/
123-
private function getAttributes()
128+
private function getAttributes(): array
124129
{
130+
if ($this->attributes) {
131+
return $this->attributes;
132+
}
133+
125134
$searchResult = $this->attributeRepository->getList(
126135
$this->searchCriteriaBuilder->addFilters(
127136
[
@@ -133,11 +142,12 @@ private function getAttributes()
133142
]
134143
)->create()
135144
);
136-
$result = [];
145+
146+
$this->attributes = [];
137147
foreach ($searchResult->getItems() as $attribute) {
138-
$result[$attribute->getAttributeCode()] = $attribute;
148+
$this->attributes[$attribute->getAttributeCode()] = $attribute;
139149
}
140150

141-
return $result;
151+
return $this->attributes;
142152
}
143153
}

0 commit comments

Comments
 (0)