Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateBundleRelatedEntityTytpes.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Eav\Setup\EavSetupFactory;
16 
22 {
26  private $moduleDataSetup;
27 
31  private $eavSetupFactory;
32 
38  public function __construct(
39  ModuleDataSetupInterface $moduleDataSetup,
40  \Magento\Eav\Setup\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 
55  $eavSetup->addAttributeGroup(
58  'Bundle Items',
59  16
60  );
61  $this->upgradePriceType($eavSetup);
62  $this->upgradeSkuType($eavSetup);
63  $this->upgradeWeightType($eavSetup);
64  $this->upgradeShipmentType($eavSetup);
65  }
66 
73  private function upgradePriceType(EavSetup $eavSetup)
74  {
75  $eavSetup->updateAttribute(
77  'price_type',
78  'frontend_input',
79  'boolean',
80  31
81  );
82  $eavSetup->updateAttribute(
84  'price_type',
85  'frontend_label',
86  'Dynamic Price'
87  );
88  $eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'price_type', 'default_value', 0);
89  }
90 
97  private function upgradeSkuType(EavSetup $eavSetup)
98  {
99  $eavSetup->updateAttribute(
101  'sku_type',
102  'frontend_input',
103  'boolean',
104  21
105  );
106  $eavSetup->updateAttribute(
108  'sku_type',
109  'frontend_label',
110  'Dynamic SKU'
111  );
112  $eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'sku_type', 'default_value', 0);
113  $eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'sku_type', 'is_visible', 1);
114  }
115 
122  private function upgradeWeightType(EavSetup $eavSetup)
123  {
124  $eavSetup->updateAttribute(
126  'weight_type',
127  'frontend_input',
128  'boolean',
129  71
130  );
131  $eavSetup->updateAttribute(
133  'weight_type',
134  'frontend_label',
135  'Dynamic Weight'
136  );
137  $eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'weight_type', 'default_value', 0);
138  $eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'weight_type', 'is_visible', 1);
139  }
140 
147  private function upgradeShipmentType(EavSetup $eavSetup)
148  {
150  $eavSetup->addAttributeToGroup(
153  'Bundle Items',
154  'shipment_type',
155  1
156  );
157  $eavSetup->updateAttribute(
159  'shipment_type',
160  'frontend_input',
161  'select'
162  );
163  $eavSetup->updateAttribute(
165  'shipment_type',
166  'frontend_label',
167  'Ship Bundle Items'
168  );
169  $eavSetup->updateAttribute(
171  'shipment_type',
172  'source_model',
173  \Magento\Bundle\Model\Product\Attribute\Source\Shipment\Type::class
174  );
175  $eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'shipment_type', 'default_value', 0);
176  $eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'shipment_type', 'is_visible', 1);
177  }
178 
182  public static function getDependencies()
183  {
184  return [
185  ApplyAttributesUpdate::class,
186  ];
187  }
188 
192  public static function getVersion()
193  {
194  return '2.0.2';
195  }
196 
200  public function getAliases()
201  {
202  return [];
203  }
204 }