Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddFieldsToAttributeObserver.php
Go to the documentation of this file.
1 <?php
7 
12 
17 {
21  protected $yesNo;
22 
26  protected $moduleManager;
27 
32  public function __construct(Manager $moduleManager, Source\Yesno $yesNo)
33  {
34  $this->moduleManager = $moduleManager;
35  $this->yesNo = $yesNo;
36  }
37 
42  public function execute(EventObserver $observer)
43  {
44  if (!$this->moduleManager->isOutputEnabled('Magento_Swatches')) {
45  return;
46  }
47 
49  $form = $observer->getForm();
50  $fieldset = $form->getElement('base_fieldset');
51  $yesnoSource = $this->yesNo->toOptionArray();
52  $fieldset->addField(
53  'update_product_preview_image',
54  'select',
55  [
56  'name' => 'update_product_preview_image',
57  'label' => __('Update Product Preview Image'),
58  'title' => __('Update Product Preview Image'),
59  'note' => __('Filtering by this attribute will update the product image on catalog page'),
60  'values' => $yesnoSource,
61  ],
62  'is_filterable'
63  );
64  $fieldset->addField(
65  'use_product_image_for_swatch',
66  'select',
67  [
68  'name' => 'use_product_image_for_swatch',
69  'label' => __('Use Product Image for Swatch if Possible'),
70  'title' => __('Use Product Image for Swatch if Possible'),
71  'note' => __('Allows use fallback logic for replacing swatch image with product swatch or base image'),
72  'values' => $yesnoSource
73  ],
74  'is_filterable'
75  );
76  }
77 }
__()
Definition: __.php:13
__construct(Manager $moduleManager, Source\Yesno $yesNo)