Skip to content

Commit 29d72c0

Browse files
authored
MAGETWO-56778 Value for multiple select attribute does not save
[Dragons] Pr 11 - Bugs Fixing
2 parents 95eae4e + 3d24318 commit 29d72c0

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

app/code/Magento/Eav/Model/Entity/Attribute.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ public function getIdentities()
498498
*/
499499
public function __sleep()
500500
{
501+
$this->unsetData('attribute_set_info');
501502
return array_diff(
502503
parent::__sleep(),
503504
['_localeDate', '_localeResolver', 'reservedAttributeList', 'dateTimeFormatter']

app/code/Magento/Eav/Model/Entity/AttributeLoader.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,32 @@ public function __construct(
6464
*/
6565
public function loadAllAttributes(AbstractEntity $resource, DataObject $object = null)
6666
{
67+
$suffix = $this->getLoadAllAttributesCacheSuffix($object);
68+
6769
$typeCode = $resource->getEntityType()->getEntityTypeCode();
68-
$attributes = $this->cache->getAttributes($typeCode);
70+
$attributes = $this->cache->getAttributes($typeCode, $suffix);
6971
if ($attributes) {
7072
foreach ($attributes as $attribute) {
7173
$resource->addAttribute($attribute);
7274
}
7375
return $resource;
7476
}
77+
$attributes = $this->checkAndInitAttributes($resource, $object);
7578

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+
{
7690
$attributeCodes = $this->config->getEntityAttributeCodes($resource->getEntityType(), $object);
7791
$attributes = [];
92+
7893
/**
7994
* Check and init default attributes
8095
*/
@@ -95,8 +110,23 @@ public function loadAllAttributes(AbstractEntity $resource, DataObject $object =
95110
$attribute = $resource->getAttribute($code);
96111
$attributes[] = $attribute;
97112
}
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;
100130
}
101131

102132
/**

0 commit comments

Comments
 (0)