Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateManufacturerAttribute.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 use Magento\Eav\Setup\EavSetupFactory;
16 
22 {
26  private $moduleDataSetup;
27 
31  private $eavSetupFactory;
32 
38  public function __construct(
39  ModuleDataSetupInterface $moduleDataSetup,
40  EavSetupFactory $eavSetupFactory
41  ) {
42  $this->moduleDataSetup = $moduleDataSetup;
43  $this->eavSetupFactory = $eavSetupFactory;
44  }
45 
49  public function apply()
50  {
52  $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
53  $relatedProductTypes = explode(
54  ',',
55  $eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'manufacturer', 'apply_to')
56  );
57 
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)
65  );
66  }
67  }
68 
72  public static function getDependencies()
73  {
74  return [
75  InstallInitialConfigurableAttributes::class,
76  ];
77  }
78 
82  public static function getVersion()
83  {
84  return '2.2.1';
85  }
86 
90  public function getAliases()
91  {
92  return [];
93  }
94 }
__construct(ModuleDataSetupInterface $moduleDataSetup, EavSetupFactory $eavSetupFactory)