Skip to content

Commit da77c32

Browse files
author
Michail Slabko
committed
MAGETWO-45552: Serious image issues when creating the first product in a new attribute set
1 parent 5923c2b commit da77c32

File tree

1 file changed

+26
-10
lines changed
  • app/code/Magento/Eav/Model/Entity/Attribute

1 file changed

+26
-10
lines changed

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

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,7 @@ public function organizeData($data)
190190
}
191191
if ($data['groups']) {
192192
foreach ($data['groups'] as $group) {
193-
$modelGroup = $this->_attrGroupFactory->create();
194-
$modelGroup->setId(
195-
is_numeric($group[0]) && $group[0] > 0 ? $group[0] : null
196-
)->setAttributeGroupName(
197-
$group[1]
198-
)->setAttributeSetId(
199-
$this->getId()
200-
)->setSortOrder(
201-
$group[2]
202-
);
193+
$modelGroup = $this->initGroupModel($group);
203194

204195
if ($data['attributes']) {
205196
foreach ($data['attributes'] as $attribute) {
@@ -253,6 +244,31 @@ public function organizeData($data)
253244
return $this;
254245
}
255246

247+
/**
248+
* @param array $group
249+
* @return Group
250+
*/
251+
private function initGroupModel($group)
252+
{
253+
$modelGroup = $this->_attrGroupFactory->create();
254+
$modelGroup->setId(
255+
is_numeric($group[0]) && $group[0] > 0 ? $group[0] : null
256+
)->setAttributeGroupName(
257+
$group[1]
258+
)->setAttributeSetId(
259+
$this->getId()
260+
)->setSortOrder(
261+
$group[2]
262+
);
263+
if ($modelGroup->getId()) {
264+
$group = $this->_attrGroupFactory->create()->load($modelGroup->getId());
265+
if ($group->getId()) {
266+
$modelGroup->setAttributeGroupCode($group->getAttributeGroupCode());
267+
}
268+
}
269+
return $modelGroup;
270+
}
271+
256272
/**
257273
* Validate attribute set name
258274
*

0 commit comments

Comments
 (0)