Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace ModuleNamespaceSetup;
- use MagentoEavSetupEavSetup;
- use MagentoEavSetupEavSetupFactory;
- use MagentoFrameworkSetupInstallDataInterface;
- use MagentoFrameworkSetupModuleContextInterface;
- use MagentoFrameworkSetupModuleDataSetupInterface;
- class InstallData implements InstallDataInterface
- {
- /**
- * Customer setup factory
- *
- * @var MagentoCustomerSetupCustomerSetupFactory
- */
- private $_eavSetupFactory;
- /**
- * Init
- *
- * @param MagentoCustomerSetupCustomerSetupFactory
- * $customerSetupFactory
- */
- public function __construct(
- MagentoEavSetupEavSetupFactory $eavSetupFactory
- ) {
- $this->_eavSetupFactory = $eavSetupFactory;
- }
- /**
- * Installs DB schema for a module
- *
- * @param ModuleDataSetupInterface $setup
- * @param ModuleContextInterface $context
- * @return void
- */
- public function install(
- ModuleDataSetupInterface $setup,
- ModuleContextInterface $context
- ) {
- /** @var EavSetup $eavSetup */
- $eavSetup = $this->_eavSetupFactory->create([
- 'setup' => $setup
- ]);
- /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
- $eavSetup->addAttribute(MagentoCatalogModelProduct::ENTITY,
- 'is_feature', [
- 'group' => 'Product Details',
- 'type' => 'int',
- 'backend' => '',
- 'frontend' => '',
- 'label' => 'Is Feature',
- 'input' => 'select',
- 'source' =>
- 'MagentoEavModelEntityAttributeSourceBoolean',
- 'visible' => true,
- 'default' => '0',
- 'frontend' => '',
- 'unique' => false,
- 'note' => '',
- 'required' => false,
- 'sort_order' => '',
- 'global' =>
- MagentoEavModelEntityAttribute
- ScopedAttributeInterface::SCOPE_GLOBAL,
- 'used_in_product_listing' => true,
- 'visible_on_front' => true
- ]);
- }
- }
- sudo rm -rf var/di var/generation var/cache
- sudo php bin/magento setup:upgrade
- sudo php bin/magento setup:di:compile
- sudo php bin/magento clear:cache
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement