Beispiel #1
0
 /**
  * Get options
  *
  * @return array
  */
 public function toOptionArray()
 {
     if ($this->options === null) {
         $this->options = $this->collectionFactory->create()->toOptionArray();
     }
     return $this->options;
 }
Beispiel #2
0
 /**
  * Render elemnt
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $html = '';
     $statuses = $this->_orderStatusCollection->create()->load()->toOptionHash();
     foreach ($statuses as $id => $status) {
         $html .= $this->_getFieldHtml($element, $id, $status);
     }
     return $html;
 }
Beispiel #3
0
 /**
  * Retrieve statuses available for state
  * Get all possible statuses, or for specified state, or specified states array
  * Add labels by default. Return plain array of statuses, if no labels.
  *
  * @param mixed $state
  * @param bool $addLabels
  * @return array
  */
 public function getStateStatuses($state, $addLabels = true)
 {
     $key = md5(serialize(array($state, $addLabels)));
     if (isset($this->stateStatuses[$key])) {
         return $this->stateStatuses[$key];
     }
     $statuses = array();
     if (!is_array($state)) {
         $state = array($state);
     }
     foreach ($state as $_state) {
         $stateNode = $this->_getState($_state);
         if ($stateNode) {
             $collection = $this->orderStatusCollectionFactory->create()->addStateFilter($_state)->orderByLabel();
             foreach ($collection as $item) {
                 $status = $item->getData('status');
                 if ($addLabels) {
                     $statuses[$status] = $item->getStoreLabel();
                 } else {
                     $statuses[] = $status;
                 }
             }
         }
     }
     $this->stateStatuses[$key] = $statuses;
     return $statuses;
 }
Beispiel #4
0
 /**
  * Prepare form fields
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'method' => 'post']]);
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Assignment Information')]);
     $statuses = $this->_collectionFactory->create()->toOptionArray();
     array_unshift($statuses, ['value' => '', 'label' => '']);
     $states = $this->_orderConfig->getStates();
     $states = array_merge(['' => ''], $states);
     $fieldset->addField('status', 'select', ['name' => 'status', 'label' => __('Order Status'), 'class' => 'required-entry', 'values' => $statuses, 'required' => true]);
     $fieldset->addField('state', 'select', ['name' => 'state', 'label' => __('Order State'), 'class' => 'required-entry', 'values' => $states, 'required' => true]);
     $fieldset->addField('is_default', 'checkbox', ['name' => 'is_default', 'label' => __('Use Order Status As Default'), 'value' => 1]);
     $fieldset->addField('visible_on_front', 'checkbox', ['name' => 'visible_on_front', 'label' => __('Visible On Frontend'), 'value' => 1]);
     $form->setAction($this->getUrl('sales/order_status/assignPost'));
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Beispiel #5
0
 /**
  * Return option array
  *
  * @return array
  */
 public function toOptionArray()
 {
     $statuses = $this->_statusCollectionFactory->create()->toOptionHash();
     return $statuses;
 }
Beispiel #6
0
 /**
  * Constructor
  *
  * @param ContextInterface $context
  * @param UiComponentFactory $uiComponentFactory
  * @param CollectionFactory $collectionFactory
  * @param array $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, CollectionFactory $collectionFactory, array $components = [], array $data = [])
 {
     $this->statuses = $collectionFactory->create()->toOptionHash();
     parent::__construct($context, $uiComponentFactory, $components, $data);
 }