Skip to content

Commit 240bee1

Browse files
ENGCOM-3603: Fixed upgrade issue if manufacturer attribute not exist in the database #19514
- Merge Pull Request #19514 from suneet64/magento2:2.3-develop - Merged commits: 1. 2c3a0ef 2. b3a21c4 3. d53ae02
2 parents 5498231 + d53ae02 commit 240bee1

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 ($manufacturer = $eavSetup->getAttribute(
55+
\Magento\Catalog\Model\Product::ENTITY,
56+
'manufacturer',
57+
'apply_to'
58+
)) {
59+
$relatedProductTypes = explode(
60+
',',
61+
$manufacturer
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)