Ejemplo n.º 1
0
 /**
  * Provides general error information
  *
  * @return void
  */
 protected function _addGeneralError()
 {
     if (!$this->_hasError) {
         $this->_getNotifier()->addMajor(__('Google Shopping Error'), $this->_gleShoppingCategory->getMessage());
         $this->_hasError = true;
     }
 }
Ejemplo n.º 2
0
 /**
  * Prepare form before rendering HTML
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     $form = $this->_formFactory->create();
     $itemType = $this->getItemType();
     $fieldset = $form->addFieldset('content_fieldset', ['legend' => __('Attribute set mapping')]);
     if (!($targetCountry = $itemType->getTargetCountry())) {
         $isoKeys = array_keys($this->_getCountriesArray());
         $targetCountry = isset($isoKeys[0]) ? $isoKeys[0] : null;
     }
     $countrySelect = $fieldset->addField('select_target_country', 'select', ['label' => __('Target Country'), 'title' => __('Target Country'), 'name' => 'target_country', 'required' => true, 'options' => $this->_getCountriesArray(), 'value' => $targetCountry]);
     if ($itemType->getTargetCountry()) {
         $countrySelect->setDisabled(true);
     }
     $attributeSetsSelect = $this->getAttributeSetsSelectElement($targetCountry)->setValue($itemType->getAttributeSetId());
     if ($itemType->getAttributeSetId()) {
         $attributeSetsSelect->setDisabled(true);
     }
     $fieldset->addField('attribute_set', 'note', ['label' => __('Attribute Set'), 'title' => __('Attribute Set'), 'required' => true, 'text' => '<div id="attribute_set_select">' . $attributeSetsSelect->toHtml() . '</div>']);
     $categories = $this->_googleShoppingCategory->getCategories();
     $fieldset->addField('category', 'select', ['label' => __('Google Product Category'), 'title' => __('Google Product Category'), 'required' => true, 'name' => 'category', 'options' => array_combine($categories, array_map('htmlspecialchars_decode', $categories)), 'value' => $itemType->getCategory()]);
     $attributesBlock = $this->getLayout()->createBlock('Magento\\GoogleShopping\\Block\\Adminhtml\\Types\\Edit\\Attributes')->setTargetCountry($targetCountry);
     if ($itemType->getId()) {
         $attributesBlock->setAttributeSetId($itemType->getAttributeSetId())->setAttributeSetSelected(true);
     }
     $attributes = $this->_coreRegistry->registry('attributes');
     if (is_array($attributes) && count($attributes) > 0) {
         $attributesBlock->setAttributesData($attributes);
     }
     $fieldset->addField('attributes_box', 'note', ['label' => __('Attributes Mapping'), 'text' => '<div id="attributes_details">' . $attributesBlock->toHtml() . '</div>']);
     $form->addValues($itemType->getData());
     $form->setUseContainer(true);
     $form->setId('edit_form');
     $form->setMethod('post');
     $form->setAction($this->getSaveUrl());
     $this->setForm($form);
     return parent::_prepareForm();
 }