Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateGiftMessageAttribute.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Setup\CategorySetupFactory;
14 
20 {
24  private $moduleDataSetup;
25 
29  private $categorySetupFactory;
30 
36  public function __construct(
37  \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
38  CategorySetupFactory $categorySetupFactory
39  ) {
40  $this->moduleDataSetup = $moduleDataSetup;
41  $this->categorySetupFactory = $categorySetupFactory;
42  }
43 
47  public function apply()
48  {
49  $this->moduleDataSetup->getConnection()->startSetup();
50 
52  $categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
53  $entityTypeId = $categorySetup->getEntityTypeId(Product::ENTITY);
54  $attribute = $categorySetup->getAttribute($entityTypeId, 'gift_message_available');
55  $categorySetup->updateAttribute(
57  $attribute['attribute_id'],
58  'source_model',
59  \Magento\Catalog\Model\Product\Attribute\Source\Boolean::class
60  );
61  $this->moduleDataSetup->getConnection()->endSetup();
62  }
63 
67  public static function getDependencies()
68  {
69  return [
70  MoveGiftMessageToGiftOptionsGroup::class
71  ];
72  }
73 
77  public static function getVersion()
78  {
79  return '2.1.0';
80  }
81 
85  public function getAliases()
86  {
87  return [];
88  }
89 }
__construct(\Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup, CategorySetupFactory $categorySetupFactory)