Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProductAttributeFormBuildFrontTabObserver.php
Go to the documentation of this file.
1 <?php
9 
13 
15 {
19  protected $optionList;
20 
24  protected $moduleManager;
25 
31  {
32  $this->optionList = $optionList;
33  $this->moduleManager = $moduleManager;
34  }
35 
40  public function execute(\Magento\Framework\Event\Observer $observer)
41  {
42  if (!$this->moduleManager->isOutputEnabled('Magento_LayeredNavigation')) {
43  return;
44  }
45 
47  $form = $observer->getForm();
48 
49  $fieldset = $form->getElement('front_fieldset');
50 
51  $fieldset->addField(
52  'is_filterable',
53  'select',
54  [
55  'name' => 'is_filterable',
56  'label' => __("Use in Layered Navigation"),
57  'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
58  'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'),
59  'values' => [
60  ['value' => '0', 'label' => __('No')],
61  ['value' => '1', 'label' => __('Filterable (with results)')],
62  ['value' => '2', 'label' => __('Filterable (no results)')],
63  ],
64  ]
65  );
66 
67  $fieldset->addField(
68  'is_filterable_in_search',
69  'select',
70  [
71  'name' => 'is_filterable_in_search',
72  'label' => __("Use in Search Results Layered Navigation"),
73  'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
74  'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'),
75  'values' => $this->optionList->toOptionArray(),
76  ]
77  );
78 
79  $fieldset->addField(
80  'position',
81  'text',
82  [
83  'name' => 'position',
84  'label' => __('Position'),
85  'title' => __('Position in Layered Navigation'),
86  'note' => __('Position of attribute in layered navigation block.'),
87  'class' => 'validate-digits'
88  ]
89  );
90  }
91 }
__()
Definition: __.php:13