Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace VendorNameModuleNameSetup;
- use MagentoEavSetupEavSetup;
- use MagentoEavSetupEavSetupFactory;
- use MagentoFrameworkSetupInstallDataInterface;
- use MagentoFrameworkSetupModuleContextInterface;
- use MagentoFrameworkSetupModuleDataSetupInterface;
- class InstallData implements InstallDataInterface
- {
- private $eavSetupFactory;
- /**
- * Init
- *
- * @param EavSetupFactory $eavSetupFactory
- */
- public function __construct(EavSetupFactory $eavSetupFactory)
- {
- $this->eavSetupFactory = $eavSetupFactory;
- }
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- /** @var EavSetup $eavSetup */
- $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
- /**
- * Add attributes to the eav/attribute
- */
- $eavSetup->addAttribute(
- MagentoCatalogModelProduct::ENTITY,
- 'custom_attribute',
- [
- 'group' => 'General',
- 'type' => 'int',
- 'backend' => '',
- 'frontend' => '',
- 'label' => 'Custom Label',
- 'input' => 'boolean',
- 'class' => '',
- 'source' => MagentoEavModelEntityAttributeSourceBoolean::class,
- 'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
- 'visible' => true,
- 'required' => false,
- 'user_defined' => false,
- 'default' => '1',
- 'searchable' => false,
- 'filterable' => false,
- 'comparable' => false,
- 'visible_on_front' => false,
- 'used_in_product_listing' => false,
- 'unique' => false,
- 'apply_to' => 'simple,configurable,virtual,bundle,downloadable'
- ]
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement