Smile\ElasticsuiteVirtualCategory\Setup\InstallData::install PHP Method

install() public method

public install ( Magento\Framework\Setup\ModuleDataSetupInterface $setup, Magento\Framework\Setup\ModuleContextInterface $context ) : void
$setup Magento\Framework\Setup\ModuleDataSetupInterface The setup interface
$context Magento\Framework\Setup\ModuleContextInterface The module Context
return void
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
        $eavSetup->addAttribute(Category::ENTITY, 'is_virtual_category', ['type' => 'int', 'label' => 'Is virtual category', 'input' => null, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'required' => false, 'default' => 0, 'visible' => true, 'note' => "Is the category is virtual or not ?", 'sort_order' => 200, 'group' => 'General Information']);
        $eavSetup->addAttribute(Category::ENTITY, 'virtual_category_root', ['type' => 'int', 'label' => 'Virtual category root', 'input' => null, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'required' => false, 'default' => 0, 'visible' => true, 'note' => "Root display of the virtual category (usefull to display a facet category on virtual).", 'sort_order' => 200, 'group' => 'General Information']);
        $eavSetup->addAttribute(Category::ENTITY, 'virtual_rule', ['type' => 'text', 'label' => 'Virtual rule', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'backend' => 'Smile\\ElasticsuiteVirtualCategory\\Model\\Category\\Attribute\\Backend\\VirtualRule', 'required' => false, 'default' => null, 'visible' => true, 'note' => "Virtual category rule.", 'sort_order' => 210, 'group' => 'General Information']);
        // Force the frontend input to be null for these attributes since they are managed by code.
        $eavSetup->updateAttribute(Category::ENTITY, 'is_virtual_category', 'frontend_input', null);
        $eavSetup->updateAttribute(Category::ENTITY, 'virtual_category_root', 'frontend_input', null);
        $eavSetup->updateAttribute(Category::ENTITY, 'virtual_rule', 'frontend_input', null);
        $setup->endSetup();
    }