/**
  * Prepares values options to be used as select options or hashed array
  * Result is stored in following keys:
  *  'value_select_options' - normal select array: array(array('value' => $value, 'label' => $label), ...)
  *  'value_option' - hashed array: array($value => $label, ...),
  *
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _prepareValueOptions()
 {
     // Check that both keys exist. Maybe somehow only one was set not in this routine, but externally.
     $selectReady = $this->getData('value_select_options');
     $hashedReady = $this->getData('value_option');
     if ($selectReady && $hashedReady) {
         return $this;
     }
     // Get array of select options. It will be used as source for hashed options
     $selectOptions = null;
     if ($this->getAttribute() === 'attribute_set_id') {
         $entityTypeId = $this->_config->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId();
         $selectOptions = $this->_attrSetCollection->setEntityTypeFilter($entityTypeId)->load()->toOptionArray();
     } elseif ($this->getAttribute() === 'type_id') {
         foreach ($selectReady as $value => $label) {
             if (is_array($label) && isset($label['value'])) {
                 $selectOptions[] = $label;
             } else {
                 $selectOptions[] = ['value' => $value, 'label' => $label];
             }
         }
         $selectReady = null;
     } elseif (is_object($this->getAttributeObject())) {
         $attributeObject = $this->getAttributeObject();
         if ($attributeObject->usesSource()) {
             if ($attributeObject->getFrontendInput() == 'multiselect') {
                 $addEmptyOption = false;
             } else {
                 $addEmptyOption = true;
             }
             $selectOptions = $attributeObject->getSource()->getAllOptions($addEmptyOption);
         }
     }
     $this->_setSelectOptions($selectOptions, $selectReady, $hashedReady);
     return $this;
 }