문제

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;
}`
도움이 되었습니까?

해결책

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;


}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top