Skip to content

Commit c9cd41f

Browse files
ENGCOM-3609: Fixed fatal error if upgrading from Magento v2.0.0 to v2.3 and non system attributes missing #19530
- Merge Pull Request #19530 from suneet64/magento2:configurable-product-attribute-fix - Merged commits: 1. eb05687
2 parents d88cf06 + eb05687 commit c9cd41f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

app/code/Magento/ConfigurableProduct/Setup/Patch/Data/InstallInitialConfigurableAttributes.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,21 @@ public function apply()
6464
'color'
6565
];
6666
foreach ($attributes as $attributeCode) {
67-
$relatedProductTypes = explode(
68-
',',
69-
$eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode, 'apply_to')
70-
);
71-
if (!in_array(Configurable::TYPE_CODE, $relatedProductTypes)) {
72-
$relatedProductTypes[] = Configurable::TYPE_CODE;
73-
$eavSetup->updateAttribute(
74-
\Magento\Catalog\Model\Product::ENTITY,
75-
$attributeCode,
76-
'apply_to',
77-
implode(',', $relatedProductTypes)
67+
$attribute = $eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode, 'apply_to');
68+
if ($attribute) {
69+
$relatedProductTypes = explode(
70+
',',
71+
$attribute
7872
);
73+
if (!in_array(Configurable::TYPE_CODE, $relatedProductTypes)) {
74+
$relatedProductTypes[] = Configurable::TYPE_CODE;
75+
$eavSetup->updateAttribute(
76+
\Magento\Catalog\Model\Product::ENTITY,
77+
$attributeCode,
78+
'apply_to',
79+
implode(',', $relatedProductTypes)
80+
);
81+
}
7982
}
8083
}
8184
}

0 commit comments

Comments
 (0)