Example #1
0
 /**
  * @return array
  */
 protected function _getAdditionalElementTypes()
 {
     $result = ['price' => 'Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Price', 'image' => 'Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Image', 'boolean' => 'Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Boolean'];
     $response = new \Magento\Framework\Object();
     $response->setTypes([]);
     $this->_eventManager->dispatch('adminhtml_catalog_product_edit_element_types', ['response' => $response]);
     foreach ($response->getTypes() as $typeName => $typeClass) {
         $result[$typeName] = $typeClass;
     }
     return $result;
 }
Example #2
0
 /**
  * Get product input types as option array
  *
  * @return array
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function toOptionArray()
 {
     $inputTypes = [['value' => 'price', 'label' => __('Price')], ['value' => 'media_image', 'label' => __('Media Image')]];
     $response = new \Magento\Framework\Object();
     $response->setTypes([]);
     $this->_eventManager->dispatch('adminhtml_product_attribute_types', ['response' => $response]);
     $_hiddenFields = [];
     foreach ($response->getTypes() as $type) {
         $inputTypes[] = $type;
         if (isset($type['hide_fields'])) {
             $_hiddenFields[$type['value']] = $type['hide_fields'];
         }
     }
     if ($this->_coreRegistry->registry('attribute_type_hidden_fields') === null) {
         $this->_coreRegistry->register('attribute_type_hidden_fields', $_hiddenFields);
     }
     return array_merge(parent::toOptionArray(), $inputTypes);
 }
Example #3
0
 /**
  * Adding product form elements for editing attribute
  *
  * @return $this
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 protected function _prepareForm()
 {
     parent::_prepareForm();
     /** @var \Magento\Catalog\Model\Resource\Eav\Attribute $attributeObject */
     $attributeObject = $this->getAttributeObject();
     /* @var $form \Magento\Framework\Data\Form */
     $form = $this->getForm();
     /* @var $fieldset \Magento\Framework\Data\Form\Element\Fieldset */
     $fieldset = $form->getElement('base_fieldset');
     $fiedsToRemove = ['attribute_code', 'is_unique', 'frontend_class'];
     foreach ($fieldset->getElements() as $element) {
         /** @var \Magento\Framework\Data\Form\AbstractForm $element  */
         if (substr($element->getId(), 0, strlen('default_value')) == 'default_value') {
             $fiedsToRemove[] = $element->getId();
         }
     }
     foreach ($fiedsToRemove as $id) {
         $fieldset->removeField($id);
     }
     $frontendInputElm = $form->getElement('frontend_input');
     $additionalTypes = [['value' => 'price', 'label' => __('Price')], ['value' => 'media_image', 'label' => __('Media Image')]];
     $additionalReadOnlyTypes = ['gallery' => __('Gallery')];
     if (isset($additionalReadOnlyTypes[$attributeObject->getFrontendInput()])) {
         $additionalTypes[] = ['value' => $attributeObject->getFrontendInput(), 'label' => $additionalReadOnlyTypes[$attributeObject->getFrontendInput()]];
     }
     $response = new \Magento\Framework\Object();
     $response->setTypes([]);
     $this->_eventManager->dispatch('adminhtml_product_attribute_types', ['response' => $response]);
     $_disabledTypes = [];
     $_hiddenFields = [];
     foreach ($response->getTypes() as $type) {
         $additionalTypes[] = $type;
         if (isset($type['hide_fields'])) {
             $_hiddenFields[$type['value']] = $type['hide_fields'];
         }
     }
     $this->_coreRegistry->register('attribute_type_hidden_fields', $_hiddenFields);
     $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
     $frontendInputElm->setValues($frontendInputValues);
     return $this;
 }
Example #4
0
 /**
  * Retrieve additional element types
  *
  * @return array
  */
 protected function _getAdditionalElementTypes()
 {
     $result = array('price' => 'Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Price', 'weight' => 'Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Weight', 'gallery' => 'Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Gallery', 'image' => 'Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Image', 'boolean' => 'Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Boolean', 'textarea' => 'Magento\\Catalog\\Block\\Adminhtml\\Helper\\Form\\Wysiwyg');
     $response = new \Magento\Framework\Object();
     $response->setTypes(array());
     $this->_eventManager->dispatch('adminhtml_catalog_product_edit_element_types', array('response' => $response));
     foreach ($response->getTypes() as $typeName => $typeClass) {
         $result[$typeName] = $typeClass;
     }
     return $result;
 }