eavSetupFactory = $eavSetupFactory; $this->categorySetupFactory = $categorySetupFactory; } /** * {@inheritdoc} */ public function install( ModuleDataSetupInterface $setup, ModuleContextInterface $context ) { $setup->startSetup(); $this->_install($setup); $setup->endSetup(); } private function _install(ModuleDataSetupInterface $setup) { $tablefields = $this->fields(); if (!empty($tablefields)) { $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]); $entityTypeId = $categorySetup->getEntityTypeId(Category::ENTITY); $attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId); foreach ($tablefields as $entity => $fields) { foreach ($fields as $key => $value) { if (Category::ENTITY == $entity) { $categorySetup->addAttribute($entity, $key, $value); $group = $value['group']; $idg = $categorySetup->getAttributeGroupId($entityTypeId, $attributeSetId, $group); $categorySetup->addAttributeToGroup( $entityTypeId, $attributeSetId, $idg, $key, $value['sort_order'] ); } else { $eavSetup->addAttribute($entity, $key, $value); } } } } } private function fields() { return [ Category::ENTITY => [ 'ox_nav_disable_ajax' => [ 'type' => 'int', 'label' => 'Disable AJAX in Layered Navigation', 'input' => 'select', 'source' => Boolean::class, 'required' => false, 'sort_order' => 10, 'group' => 'Display Settings', 'default' => 0, ], ], ]; } }