Skip to content

Commit 2c3a0ef

Browse files
Fixed upgrade issue if manufacturer attribute not exist in the database
1 parent 5498231 commit 2c3a0ef

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,26 @@ public function apply()
5050
{
5151
/** @var EavSetup $eavSetup */
5252
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
53-
$relatedProductTypes = explode(
54-
',',
55-
$eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'manufacturer', 'apply_to')
56-
);
5753

58-
if (!in_array(Configurable::TYPE_CODE, $relatedProductTypes)) {
59-
$relatedProductTypes[] = Configurable::TYPE_CODE;
60-
$eavSetup->updateAttribute(
61-
\Magento\Catalog\Model\Product::ENTITY,
62-
'manufacturer',
63-
'apply_to',
64-
implode(',', $relatedProductTypes)
54+
if($manufacturerAttribute = $eavSetup->getAttribute(
55+
\Magento\Catalog\Model\Product::ENTITY,
56+
'manufacturer',
57+
'apply_to')
58+
) {
59+
$relatedProductTypes = explode(
60+
',',
61+
$manufacturerAttribute
6562
);
63+
64+
if (!in_array(Configurable::TYPE_CODE, $relatedProductTypes)) {
65+
$relatedProductTypes[] = Configurable::TYPE_CODE;
66+
$eavSetup->updateAttribute(
67+
\Magento\Catalog\Model\Product::ENTITY,
68+
'manufacturer',
69+
'apply_to',
70+
implode(',', $relatedProductTypes)
71+
);
72+
}
6673
}
6774
}
6875

0 commit comments

Comments
 (0)