UpgradeData.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /**
  3. * Copyright © 2018 Porto. All rights reserved.
  4. */
  5. namespace Smartwave\Porto\Setup;
  6. use Magento\Eav\Setup\EavSetup;
  7. use Magento\Eav\Setup\EavSetupFactory;
  8. use Magento\Framework\Setup\UpgradeDataInterface;
  9. use Magento\Framework\Setup\ModuleContextInterface;
  10. use Magento\Framework\Setup\ModuleDataSetupInterface;
  11. /**
  12. * @codeCoverageIgnore
  13. */
  14. class UpgradeData implements UpgradeDataInterface {
  15. /**
  16. * EAV setup factory
  17. *
  18. * @var EavSetupFactory
  19. */
  20. private $eavSetupFactory;
  21. /**
  22. * Init
  23. *
  24. * @param EavSetupFactory $eavSetupFactory
  25. */
  26. public function __construct(EavSetupFactory $eavSetupFactory) {
  27. $this->eavSetupFactory = $eavSetupFactory;
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
  33. $installer = $setup;
  34. $installer->startSetup();
  35. if (version_compare($context->getVersion(), '3.1.0') < 0) {
  36. /** @var EavSetup $eavSetup */
  37. $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
  38. $eavSetup->addAttribute(
  39. \Magento\Catalog\Model\Product::ENTITY, 'product_page_type', [
  40. 'group' => 'Product Details',
  41. 'type' => 'varchar',
  42. 'sort_order' => 200,
  43. 'backend' => '',
  44. 'frontend' => '',
  45. 'label' => 'Product Page Type',
  46. 'input' => 'select',
  47. 'source' => 'Smartwave\Porto\Model\Attribute\Productpagetype',
  48. 'class' => '',
  49. 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
  50. 'visible' => true,
  51. 'required' => false,
  52. 'user_defined' => true,
  53. 'default' => '',
  54. 'searchable' => false,
  55. 'filterable' => false,
  56. 'comparable' => false,
  57. 'visible_on_front' => false,
  58. 'used_in_product_listing' => false,
  59. 'unique' => false,
  60. 'wysiwyg_enabled' => false,
  61. 'apply_to' => 'simple,configurable,virtual,bundle,downloadable'
  62. ]);
  63. $eavSetup->addAttribute(
  64. \Magento\Catalog\Model\Product::ENTITY, 'product_image_size', [
  65. 'group' => 'Product Details',
  66. 'type' => 'varchar',
  67. 'sort_order' => 201,
  68. 'backend' => '',
  69. 'frontend' => '',
  70. 'label' => 'Product Image Size',
  71. 'input' => 'select',
  72. 'source' => 'Smartwave\Porto\Model\Attribute\Productimagesize',
  73. 'class' => '',
  74. 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
  75. 'visible' => true,
  76. 'required' => false,
  77. 'user_defined' => true,
  78. 'default' => '',
  79. 'searchable' => false,
  80. 'filterable' => false,
  81. 'comparable' => false,
  82. 'visible_on_front' => false,
  83. 'used_in_product_listing' => false,
  84. 'unique' => false,
  85. 'wysiwyg_enabled' => false,
  86. 'apply_to' => 'simple,configurable,virtual,bundle,downloadable'
  87. ]);
  88. $eavSetup->addAttribute(
  89. \Magento\Catalog\Model\Product::ENTITY, 'custom_block', [
  90. 'group' => 'Product Details',
  91. 'type' => 'text',
  92. 'sort_order' => 202,
  93. 'backend' => '',
  94. 'frontend' => '',
  95. 'label' => 'Custom Block',
  96. 'input' => 'textarea',
  97. 'class' => '',
  98. 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
  99. 'visible' => true,
  100. 'required' => false,
  101. 'user_defined' => true,
  102. 'default' => '',
  103. 'searchable' => false,
  104. 'filterable' => false,
  105. 'comparable' => false,
  106. 'visible_on_front' => false,
  107. 'used_in_product_listing' => false,
  108. 'unique' => false,
  109. 'wysiwyg_enabled' => true,
  110. 'apply_to' => 'simple,configurable,virtual,bundle,downloadable'
  111. ]);
  112. $eavSetup->addAttribute(
  113. \Magento\Catalog\Model\Product::ENTITY, 'custom_block_2', [
  114. 'group' => 'Product Details',
  115. 'type' => 'text',
  116. 'sort_order' => 203,
  117. 'backend' => '',
  118. 'frontend' => '',
  119. 'label' => 'Custom Block 2',
  120. 'input' => 'textarea',
  121. 'class' => '',
  122. 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
  123. 'visible' => true,
  124. 'required' => false,
  125. 'user_defined' => true,
  126. 'default' => '',
  127. 'searchable' => false,
  128. 'filterable' => false,
  129. 'comparable' => false,
  130. 'visible_on_front' => false,
  131. 'used_in_product_listing' => false,
  132. 'unique' => false,
  133. 'wysiwyg_enabled' => true,
  134. 'apply_to' => 'simple,configurable,virtual,bundle,downloadable'
  135. ]);
  136. }
  137. $setup->endSetup();
  138. }
  139. }