Ejemplo n.º 1
0
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function prepareForm($observer)
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getForm();
     foreach ($form->getElements() as $element) {
         /** @var \Magento\Framework\Data\Form\Element\AbstractElement $element */
         if ($element->getId() == 'action_fieldset') {
             $element->addField('simple_free_shipping', 'select', array('label' => __('Free Shipping'), 'title' => __('Free Shipping'), 'name' => 'simple_free_shipping', 'options' => array(0 => __('No'), Rule::FREE_SHIPPING_ITEM => __('For matching items only'), Rule::FREE_SHIPPING_ADDRESS => __('For shipment with matching items'))));
         }
     }
 }
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getForm();
     foreach ($form->getElements() as $element) {
         /** @var \Magento\Framework\Data\Form\Element\AbstractElement $element */
         if ($element->getId() != 'action_fieldset') {
             continue;
         }
         $element->addField('simple_free_shipping', 'select', ['label' => __('Free Shipping'), 'title' => __('Free Shipping'), 'name' => 'simple_free_shipping', 'options' => [0 => __('No'), Rule::FREE_SHIPPING_ITEM => __('For matching items only'), Rule::FREE_SHIPPING_ADDRESS => __('For shipment with matching items')]]);
     }
 }
 /**
  * @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');
 }
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->moduleManager->isOutputEnabled('Magento_LayeredNavigation')) {
         return;
     }
     /** @var \Magento\Framework\Data\Form\AbstractForm $form */
     $form = $observer->getForm();
     $fieldset = $form->getElement('front_fieldset');
     $fieldset->addField('is_filterable', 'select', ['name' => 'is_filterable', 'label' => __("Use in Layered Navigation"), 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), 'values' => [['value' => '0', 'label' => __('No')], ['value' => '1', 'label' => __('Filterable (with results)')], ['value' => '2', 'label' => __('Filterable (no results)')]]]);
     $fieldset->addField('is_filterable_in_search', 'select', ['name' => 'is_filterable_in_search', 'label' => __("Use in Search Results Layered Navigation"), 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), 'values' => $this->optionList->toOptionArray()]);
     $fieldset->addField('position', 'text', ['name' => 'position', 'label' => __('Position'), 'title' => __('Position in Layered Navigation'), 'note' => __('Position of attribute in layered navigation block.'), 'class' => 'validate-digits']);
 }
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if (!$this->isVariationsPopupUsed()) {
         return;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getForm();
     $filteredValues = [];
     /** @var \Magento\Framework\Data\Form\Element\Select $frontendInput */
     $frontendInput = $form->getElement('frontend_input');
     foreach ($frontendInput->getValues() as $frontendValue) {
         if (in_array($frontendValue['value'], $this->supportedTypes, true)) {
             $filteredValues[] = $frontendValue;
         }
     }
     $frontendInput->setValues($filteredValues);
 }
Ejemplo n.º 6
0
 public function addFieldToAttributeEditForm(\Magento\Framework\Event\Observer $observer)
 {
     // Add an extra field to the base fieldset:
     $fieldset = $observer->getForm()->getElement('base_fieldset');
     $fieldset->addField('description', 'textarea', ['name' => 'description', 'label' => __('Description'), 'title' => __('Description'), 'style' => 'width: 600px;', 'required' => false]);
 }