Messages.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Adminhtml\Order\View;
  7. use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
  8. use Magento\Sales\Model\Order;
  9. /**
  10. * Order view messages
  11. *
  12. * @api
  13. * @author Magento Core Team <core@magentocommerce.com>
  14. * @since 100.0.2
  15. */
  16. class Messages extends \Magento\Framework\View\Element\Messages
  17. {
  18. /**
  19. * Core registry
  20. *
  21. * @var \Magento\Framework\Registry
  22. */
  23. protected $coreRegistry = null;
  24. /**
  25. * @param \Magento\Framework\View\Element\Template\Context $context
  26. * @param \Magento\Framework\Message\Factory $messageFactory
  27. * @param \Magento\Framework\Message\CollectionFactory $collectionFactory
  28. * @param \Magento\Framework\Message\ManagerInterface $messageManager
  29. * @param InterpretationStrategyInterface $interpretationStrategy
  30. * @param \Magento\Framework\Registry $registry
  31. * @param array $data
  32. */
  33. public function __construct(
  34. \Magento\Framework\View\Element\Template\Context $context,
  35. \Magento\Framework\Message\Factory $messageFactory,
  36. \Magento\Framework\Message\CollectionFactory $collectionFactory,
  37. \Magento\Framework\Message\ManagerInterface $messageManager,
  38. InterpretationStrategyInterface $interpretationStrategy,
  39. \Magento\Framework\Registry $registry,
  40. array $data = []
  41. ) {
  42. parent::__construct(
  43. $context,
  44. $messageFactory,
  45. $collectionFactory,
  46. $messageManager,
  47. $interpretationStrategy,
  48. $data
  49. );
  50. $this->coreRegistry = $registry;
  51. }
  52. /**
  53. * Retrieve order model instance
  54. *
  55. * @return Order
  56. */
  57. protected function _getOrder()
  58. {
  59. return $this->coreRegistry->registry('sales_order');
  60. }
  61. /**
  62. * Preparing global layout
  63. *
  64. * @return $this
  65. */
  66. protected function _prepareLayout()
  67. {
  68. /**
  69. * Check Item products existing
  70. */
  71. $productIds = [];
  72. foreach ($this->_getOrder()->getAllItems() as $item) {
  73. $productIds[] = $item->getProductId();
  74. }
  75. return parent::_prepareLayout();
  76. }
  77. }