Example #1
0
 /**
  * Build HTML code for select element which contains all available Google's attributes
  *
  * @return string
  */
 public function getGcontentAttributesSelectHtml()
 {
     $options[] = ['label' => __('Custom attribute, no mapping')];
     $attributesTree = $this->_config->getAttributesByCountry($this->getTargetCountry());
     foreach ($attributesTree as $destination => $attributes) {
         $options[] = ['label' => $destination, 'is_group' => true];
         foreach ($attributes as $attribute => $params) {
             $options[$attribute] = ['label' => $params['name']];
             if ((int) $params['required'] == 1) {
                 $options[$attribute]['style'] = 'color: #940000;';
             }
         }
         $options[] = ['is_group' => true, 'is_close' => true];
     }
     $select = $this->getLayout()->createBlock('Magento\\GoogleShopping\\Block\\Adminhtml\\Types\\Edit\\Select')->setId($this->getFieldId() . '_{{index}}_gattribute')->setName($this->getFieldName() . '[{{index}}][gcontent_attribute]')->setOptions($options);
     return $this->_toOneLineString($select->toHtml());
 }