Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. <?php
  2. namespace ModuleNamespaceSetup;
  3.  
  4. use MagentoEavSetupEavSetup;
  5. use MagentoEavSetupEavSetupFactory;
  6. use MagentoFrameworkSetupInstallDataInterface;
  7. use MagentoFrameworkSetupModuleContextInterface;
  8. use MagentoFrameworkSetupModuleDataSetupInterface;
  9.  
  10. class InstallData implements InstallDataInterface
  11. {
  12.  
  13. /**
  14. * Customer setup factory
  15. *
  16. * @var MagentoCustomerSetupCustomerSetupFactory
  17. */
  18. private $_eavSetupFactory;
  19.  
  20. /**
  21. * Init
  22. *
  23. * @param MagentoCustomerSetupCustomerSetupFactory
  24. * $customerSetupFactory
  25. */
  26. public function __construct(
  27. MagentoEavSetupEavSetupFactory $eavSetupFactory
  28. ) {
  29. $this->_eavSetupFactory = $eavSetupFactory;
  30. }
  31.  
  32. /**
  33. * Installs DB schema for a module
  34. *
  35. * @param ModuleDataSetupInterface $setup
  36. * @param ModuleContextInterface $context
  37. * @return void
  38. */
  39. public function install(
  40. ModuleDataSetupInterface $setup,
  41. ModuleContextInterface $context
  42. ) {
  43. /** @var EavSetup $eavSetup */
  44. $eavSetup = $this->_eavSetupFactory->create([
  45. 'setup' => $setup
  46. ]);
  47.  
  48. /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
  49. $eavSetup->addAttribute(MagentoCatalogModelProduct::ENTITY,
  50. 'is_feature', [
  51. 'group' => 'Product Details',
  52. 'type' => 'int',
  53. 'backend' => '',
  54. 'frontend' => '',
  55. 'label' => 'Is Feature',
  56. 'input' => 'select',
  57. 'source' =>
  58. 'MagentoEavModelEntityAttributeSourceBoolean',
  59. 'visible' => true,
  60. 'default' => '0',
  61. 'frontend' => '',
  62. 'unique' => false,
  63. 'note' => '',
  64. 'required' => false,
  65. 'sort_order' => '',
  66. 'global' =>
  67. MagentoEavModelEntityAttribute
  68. ScopedAttributeInterface::SCOPE_GLOBAL,
  69. 'used_in_product_listing' => true,
  70. 'visible_on_front' => true
  71. ]);
  72. }
  73. }
  74.  
  75. sudo rm -rf var/di var/generation var/cache
  76. sudo php bin/magento setup:upgrade
  77. sudo php bin/magento setup:di:compile
  78. sudo php bin/magento clear:cache
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement