Save.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Sales\Controller\Adminhtml\Order\View\Giftmessage;
  8. class Save extends \Magento\Sales\Controller\Adminhtml\Order\View\Giftmessage
  9. {
  10. /**
  11. * @return void
  12. */
  13. public function execute()
  14. {
  15. try {
  16. $this->_getGiftmessageSaveModel()->setGiftmessages(
  17. $this->getRequest()->getParam('giftmessage')
  18. )->saveAllInOrder();
  19. } catch (\Magento\Framework\Exception\LocalizedException $e) {
  20. $this->messageManager->addErrorMessage($e->getMessage());
  21. } catch (\Exception $e) {
  22. $this->messageManager->addErrorMessage(__('Something went wrong while saving the gift message.'));
  23. }
  24. if ($this->getRequest()->getParam('type') == 'order_item') {
  25. $this->getResponse()->setBody($this->_getGiftmessageSaveModel()->getSaved() ? 'YES' : 'NO');
  26. } else {
  27. $this->getResponse()->setBody(__('You saved the gift card message.'));
  28. }
  29. }
  30. }