Skip to content

Commit 2b8e315

Browse files
committed
MAGETWO-91335: Manufacturer attribute not appearing in Configurable Products on the backend
1 parent c3167bf commit 2b8e315

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function apply()
5151
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
5252
$attributes = [
5353
'country_of_manufacture',
54+
'manufacturer',
5455
'minimal_price',
5556
'msrp',
5657
'msrp_display_actual_price_type',
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\ConfigurableProduct\Setup\Patch\Data;
8+
9+
use Magento\Eav\Setup\EavSetup;
10+
use Magento\Eav\Setup\EavSetupFactory;
11+
use Magento\Framework\Setup\ModuleDataSetupInterface;
12+
use Magento\Framework\Setup\Patch\DataPatchInterface;
13+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
14+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
15+
16+
/**
17+
* Class UpdateManufacturerAttribute
18+
* @package Magento\ConfigurableProduct\Setup\Patch
19+
*/
20+
class UpdateManufacturerAttribute implements DataPatchInterface, PatchVersionInterface
21+
{
22+
/**
23+
* @var ModuleDataSetupInterface
24+
*/
25+
private $moduleDataSetup;
26+
27+
/**
28+
* @var EavSetupFactory
29+
*/
30+
private $eavSetupFactory;
31+
32+
/**
33+
* UpdateTierPriceAttribute constructor.
34+
* @param ModuleDataSetupInterface $moduleDataSetup
35+
* @param EavSetupFactory $eavSetupFactory
36+
*/
37+
public function __construct(
38+
ModuleDataSetupInterface $moduleDataSetup,
39+
EavSetupFactory $eavSetupFactory
40+
) {
41+
$this->moduleDataSetup = $moduleDataSetup;
42+
$this->eavSetupFactory = $eavSetupFactory;
43+
}
44+
45+
/**
46+
* {@inheritdoc}
47+
*/
48+
public function apply()
49+
{
50+
/** @var EavSetup $eavSetup */
51+
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
52+
$relatedProductTypes = explode(
53+
',',
54+
$eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'manufacturer', 'apply_to')
55+
);
56+
$key = array_search(Configurable::TYPE_CODE, $relatedProductTypes);
57+
if ($key !== false) {
58+
unset($relatedProductTypes[$key]);
59+
$eavSetup->updateAttribute(
60+
\Magento\Catalog\Model\Product::ENTITY,
61+
'manufacturer',
62+
'apply_to',
63+
implode(',', $relatedProductTypes)
64+
);
65+
}
66+
}
67+
68+
/**
69+
* {@inheritdoc}
70+
*/
71+
public static function getDependencies()
72+
{
73+
return [
74+
InstallInitialConfigurableAttributes::class,
75+
];
76+
}
77+
78+
/**
79+
* {@inheritdoc}\
80+
*/
81+
public static function getVersion()
82+
{
83+
return '2.2.1';
84+
}
85+
86+
/**
87+
* {@inheritdoc}
88+
*/
89+
public function getAliases()
90+
{
91+
return [];
92+
}
93+
}

0 commit comments

Comments
 (0)