moduleManager = $moduleManager; $this->yesNo = $yesNo; } /** * @param \Magento\Framework\Event\Observer $observer * @return void */ public function execute(EventObserver $observer) { if (!$this->moduleManager->isOutputEnabled('Magento_Swatches')) { return; } /** @var \Magento\Framework\Data\Form $form */ $form = $observer->getForm(); $fieldset = $form->getElement('base_fieldset'); $yesnoSource = $this->yesNo->toOptionArray(); $fieldset->addField( 'update_product_preview_image', 'select', [ 'name' => 'update_product_preview_image', 'label' => __('Update Product Preview Image'), 'title' => __('Update Product Preview Image'), 'note' => __('Filtering by this attribute will update the product image on catalog page'), 'values' => $yesnoSource, ], 'is_filterable' ); $fieldset->addField( 'use_product_image_for_swatch', 'select', [ 'name' => 'use_product_image_for_swatch', 'label' => __('Use Product Image for Swatch if Possible'), 'title' => __('Use Product Image for Swatch if Possible'), 'note' => __('Allows use fallback logic for replacing swatch image with product swatch or base image'), 'values' => $yesnoSource ], 'is_filterable' ); } }