Skip to content

Commit eb05687

Browse files
committed
Fixed fatal error if upgrading from Magento 2.0.0 to 2.3 and manufacturer and color attribute missing
1 parent 5498231 commit eb05687

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)