1

I have created one custom attribute for Category with Multi select option.I am trying to get dynamic values from source file but first value only printing in multi select please give solution and check my code what i did wrong. `

    $school_model = $this->_modelCreateFactory->create();
    $data = $school_model->getCollection()->getData();
    $value1 = array();
    foreach ($data as $key => $value) {
          if(!empty($value['school_id']))
          {
            if ($this->_options === null) {
                $value1[$key]['school_id'] =  $value['school_id'];
                $value1[$key]['school_name'] = $value['school_name'];

                $this->_options =[  [
                                       'value' => $value1[$key]['school_id'],
                                       'label' => __($value1[$key]['school_name'])
                                    ]
                                 ];
            }
          }
        }

    return $this->_options;
}`
5

form an array like this. It will work

// Added brands

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $collection = $objectManager->create('Vendor\Mysize\Model\Brand');
    $option = $collection->getCollection();
    $optionsArray =[];
    foreach($option as $optionValues) { 
          $optionsArray [] = [
            'label' =>  $optionValues,
            'value' => $optionValues
      ];
        }
        return $optionsArray;


}
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.