/** * Get options * * @return array */ public function toOptionArray() { if ($this->options === null) { $this->options = []; /** @var \Magento\Framework\Phrase $state */ foreach ($this->creditmemoRepository->create()->getStates() as $id => $state) { $this->options[] = ['value' => $id, 'label' => $state->render()]; } } return $this->options; }
/** * Convert order object to creditmemo * * @param \Magento\Sales\Model\Order $order * @return \Magento\Sales\Model\Order\Creditmemo */ public function toCreditmemo(\Magento\Sales\Model\Order $order) { $creditmemo = $this->creditmemoRepository->create(); $creditmemo->setOrder($order)->setStoreId($order->getStoreId())->setCustomerId($order->getCustomerId())->setBillingAddressId($order->getBillingAddressId())->setShippingAddressId($order->getShippingAddressId()); $this->_objectCopyService->copyFieldsetToTarget('sales_convert_order', 'to_cm', $order, $creditmemo); return $creditmemo; }
/** * Constructor * * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory * @param CreditmemoRepositoryInterface $creditmemoRepository * @param array $components * @param array $data */ public function __construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, CreditmemoRepositoryInterface $creditmemoRepository, array $components = [], array $data = []) { $this->states = $creditmemoRepository->create()->getStates(); parent::__construct($context, $uiComponentFactory, $components, $data); }
/** * Return option array * * @return array */ public function toOptionArray() { return $this->creditmemoRepository->create()->getStates(); }